problem in receiving data via SocketRead
Reza Babagoli:
hi i am trying to receive a message from python via Socket
the message is "hi from python" , but in mt5 terminal i only receive character "h"
please take a look at my mql5 codes and the images i attached
hi i am trying to receive a message from python via Socket
the message is "hi from python" , but in mt5 terminal i only receive character "h"
please take a look at my mql5 codes and the images i attached
Try to use CP_UTF8 in CharArrayToString. In the real world (with lengthy messages) you need to wait somehow when entire message is received before decoding it.
Documentation on MQL5: Conversion Functions / CharArrayToString
- www.mql5.com
It copies and converts part of array of uchar type into a returned string. Parameters array[] [in] Array of uchar type. start=0 [in] ...
Stanislav Korotky #:
Try to use CP_UTF8 in CharArrayToString. In the real world (with lengthy messages) you need to wait somehow when entire message is received before decoding it.
and i used timeout and sleep but nothing changed
Stanislav Korotky #:
Try to use CP_UTF8 in CharArrayToString. In the real world (with lengthy messages) you need to wait somehow when entire message is received before decoding it.
void socketreceive(int sock,int timeout) { char rsp[]; string result=""; uint len; uint timeout_check=GetTickCount()+timeout; do { len=SocketIsReadable(sock); if(len) { int rsp_len; rsp_len=SocketRead(sock,rsp,len,timeout); if(rsp_len>0) { result+=CharArrayToString(rsp,0,rsp_len); } } } while((GetTickCount()<timeout_check) && !IsStopped()); //-----------------------------------------------------------------------moved here-------------------------------- Print(result); }
the message is "hi from python" , but in mt5 terminal i only receive character "h"
please take a look at my mql5 codes and the images i attached
please help me thanks