Problem with calling socket communication functions via DLL

 

Hello,


I've build a Server implementing some neuro-network functions and i want to communicate from an EA with this server.

To do so, I implemented some socket-communication functions as an DLL but I got the following problem:


- when calling the connect - function of WinSock via the DLL I always get an error 10049 which means "illegal address " but my

server is running (localhost, Port 4711) and acccessable (tested with telnet).


Does anybody know if socket-communication is possible(allowed out of an EA or what else is going wrong ?


Juergen

 
EA can call DLL that uses socket functions. Check your DLL.
 

Hello Juergen,

can I see your source code? I need to implement socket functions in a DLL as well and definitely need some sort of starting template..

Best Regards,

Alex

 
JStein:

[...]

- when calling the connect - function of WinSock via the DLL I always get an error 10049 which means "illegal address " but my

server is running (localhost, Port 4711) and acccessable (tested with telnet).

Does anybody know if socket-communication is possible(allowed out of an EA or what else is going wrong ?

I'd be hugely surprised if it wasn't possible to do socket communication from a DLL which is being called by an EA. There's no reason why it shouldn't work, and both MetaTrader itself and various external libraries are reliant on socket communication, albeit usually indirectly, for doing things such as email and HTTP.


However, you're probably going to have far more success pursuing this question on a forum devoted to C++ and Winsock, rather than on this forum which is almost exclusively about MQL and has very few members with the expertise you need.


To start you off, the most likely reason for 10049 is that you're not build the sockaddr properly for the call to connect(). You need to be populating it along something like the following lines:


DWORD Port = whatever, IPAddress = whatever;

sockaddr_in address;

address.sin_family = AF_INET;

address.sin_port = htons(LOWORD(Port));

*(LPDWORD)&address.sin_addr = IPAddress;


 

Thanks a lot,


it was my fault (programming error, I fixed it already.

 
JStein wrote >>

Thanks a lot,

it was my fault (programming error, I fixed it already.

I am sending send signals from a central server running MT4 to other MT4 running in other PCs across a network. Do you mind sharing your source code how to initiate socket connection? My email is williamwongys@yahoo.com, thanks.

Reason: