Question

I've been at this for some time now. I need a basic IRC Ping Pong function to return the the proper response when the IRC server pings. I changed the name of the function get() to something else and I'm still getting the error. I thought perhaps the function name get() was already defined in one of the includes or something else.

#include "stdafx.h"
#include "Ping_Pong.h"
#include <iostream>
#include <ws2tcpip.h>

#ifdef _DEBUG
#define new DEBUG_NEW
#endif

CWinApp theApp;

#define MT4_EXPFUNC __declspec(dllexport)
#pragma comment(lib, "Ws2_32.lib")

class MT4_EXPFUNC IRC {

private:
    char buf[513];
    char rbuf[513];
    char sbuf[513];
    char *tok;
    int recv_bytes;
    int irc_socket;
    struct addrinfo hints;
    struct addrinfo *results;
public:
    char *nick, *user, *host, *chan, *type, *mesg;
    int irc_connect(const char *host, const char *port, const char *nick);
    void socket_err(const char* err_string);
    //int join(const char *channel);

This is the name of the function in question

    int __stdcall get();

    char *check(const char* test_str);
    char *pop_arg(char **save_ptr);
    int init_comarg();
    int say(const char *channel, const char *message);
    int sayf(const char *channel, const char *message, ...);
    int mode(const char *channel, const char *mode, char *target);
    //void die();

};

And this is the function I'm having a problem with.

MT4_EXPFUNC int __stdcall IRC::get()
    {


    memset(rbuf, 0, 513);
    recv_bytes = recv(irc_socket, rbuf, sizeof(rbuf), 0);
    if (recv_bytes <= 0) {
        return -1;
    }
    std::cout << rbuf;
    // Auto-Respond to PING messages.
    if (rbuf[0] == 'P' && rbuf[1] == 'I') {
        tok = strtok(rbuf, "PING :");
        sprintf(buf, "PONG %s", tok-1 );
        send(irc_socket, buf, strlen(buf), 0);
        std::cout << buf;
        memset(buf, 0, 513);
    }
    if ( strstr(rbuf, "PRIVMSG")) {
        memcpy(sbuf, rbuf, 513);
        nick = strtok(sbuf, "!") + 1;
        user = strtok(NULL, "@");
        host = strtok(NULL, " ");
        type = strtok(NULL, " ") - 1;
        chan = strtok(NULL, " ");
        mesg = strtok(NULL, ":");
    }
    return 1;
    }
Was it helpful?

Solution

In the tutorial linked below, a .def file was suggested with the following code:

Library "Ping_Pong"
Export   get

I removed the .def and it worked.

http://www.xpworx.com/metatrader-mql-articles/mql4-articles/create-your-own-metatrader-extension-dll.php

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top