Discussion of article "Working with sockets in MQL, or How to become a signal provider" - page 5

 
pavlick_:

I got such a synchronous TCP client:

I don't need a server on µl, so just a client. Tested superficially.

ZЫЫ: Thanks for the article.

At the compilation stage, it fails on structure conversions :-(.

'cannnot cast Data_cz_char -> Data_cz_int ' and vice versa.

Though it seemed to work before. It seems to have stopped working after another terminal update.

What is the problem? I don't understand it.

 
Dmitriy Strelnikov:

What's the problem? I don't get it.

union
 
o_o:
union


Thank you for your reply. However, the question is still relevant. MQL4 does not support unions. At least the doc says so.

Also, as I was investigating, some more questions arose:

- In the procedures send and recv the int flags parameter (the last one) is not covered in any way. In my case with send it takes value - 0, and in recv - 8, why?

- The original post says that the client is synchronous, but the example implements only sending a string to the server. What about the response ... .

Pardon me for my dummies questions. I'm trying to figure it out, but I'm not getting it yet ... if you can help me please.

I want to implement a working class for interaction with a third-party server of many clients. I am still stuck, alas.

 
Dmitriy Strelnikov:


Thanks for the reply. However, the question is still relevant. MQL4 does not support unions. At least the doc says so.

Also, as I was investigating, some more questions arose:

- In the procedures send and recv the int flags parameter (the last one) is not covered in any way. In my case with send it takes value - 0, and in recv - 8, why?

- The original post says that the client is synchronous, but the example implements only sending a string to the server. What about the response ... .

Pardon me for my dummies questions. I'm trying to figure it out, but I'm not getting it yet ... if you can help me please.

I want to implement a working class for interaction with a third-party server of many clients. I am still stuck, alas.

Forum on trading, automated trading systems and testing trading strategies

Code breaking changes in MQL4 language

Alain Verleyen, 2017.05.18 22:10


They introduced union (not documented on MT4, but works well with ME 1599) :

union Udata_32bytes 
  {
   uchar             d_uchar[32];
   ulong             d_ulong[4];
  }
data;

void OnStart()
  {
   data.d_ulong[0]=0xFFEEDDCC;
   
   printf("uchar[%i] = %X",1,data.d_uchar[1]);

  }

 
Alain Verleyen:


YES! Associations are working. THANK YOU!!! I understand that union support has been added as of 12th May 2017. Great!

It would be good for the developers to reflect this in the doc.

A simple example illustrating the work with union

//+------------------------------------------------------------------+
//| Script programme start function|
//+------------------------------------------------------------------+

union AS {
   uint intN;
   uchar c[4];
} a;

void OnStart()
  {
//---
   a.intN = 555; 
   
   // uint - 4 bytes 
   // uchar[4] - an array of 4 elements of one byte each
   // 555 decimal, this is 0000 0000 0000 0010 1011 binary 4-byte.
   // respectively, this is an array of 4 decimal digits 0 0 0 2 43 

   Alert(IntegerToString(a.intN) + ", byte by by byte " + IntegerToString(a.c[0]) + ", " + IntegerToString(a.c[1]) + ", " + IntegerToString(a.c[2]) + ", " + IntegerToString(a.c[3]));
  }
 
 
Dmitriy Strelnikov:

- In the procedures send and recv, the int flags parameter (the last one) is not covered in any way. In the case of send it takes the value 0, but in recv it takes the value 8. Why?

Because you are making things up. I don't see flags =8.

- The original post says that the client is synchronous, and the example only implements sending a string to the server. What about the response ... .

With such formulations of questions it is better to address here
 
o_o:

Because you're making it up. I don't see any flags =8

With such formulations of questions it is better to address here.


Dear GURU! I'm not in the habit of making things up. My mistake, apparently, was that the questions were addressed to the user with the nickname pavlick_ and concerned the TCP_Client class implemented by him and presented in this thread above - https://www.mql5.com/ru/forum/91150/page3#comment_2798881.

So I apologise for the disturbance. However, I did not expect such a stormy, if not to say more, reaction from you.

Believe me, sometimes it is useful to restrain your negative emotions.

Обсуждение статьи "Работа с сокетами в MQL, или Как стать провайдером сигналов"
Обсуждение статьи "Работа с сокетами в MQL, или Как стать провайдером сигналов"
  • 2016.09.08
  • www.mql5.com
Опубликована статья Работа с сокетами в MQL, или Как стать провайдером сигналов: Автор: o_O Версии библиотеки 1...
 

Ditto! Ditto question!

 
MetaQuotes Software Corp.:

New article Working with sockets in MQL, or How to become a signal provider has been published:

Author: o_O


Hi, This code works on MQL4 ?

I'm trying to port it to mql4, and when the DLL bind() function is called at MQL StartServer function, gives me the message below:

2017.09.13 18:06:30.181 Server AUDCAD,H1: try bind...0.0.0.0:8081
2017.09.13 18:06:30.181 Access violation read to 0x00000012 in 'Ws2_32.dll'


 
Wemerson Guimaraes:

Hi, This code works on MQL4 ?

source was compiled for x64

you need change all pointer to 32 bit

f.e. use SOCKET32   instead SOCKET64   etc