Damian7546 - 2017-12-11

Hi,

I wrote in CODESYS socket communication like this:

IF run = TRUE THEN
sa.sin_family       :=   SOCKET_AF_INET;
sa.sin_port         :=  SysSockHtons(port);
result            :=  SysSockInetAddr(strIpAddres, ADR(sa.sin_addr.ulAddr)); //convert Ip STRING  to IP adres
hSocket          :=   SysSockCreate(SOCKET_AF_INET, SOCKET_STREAM, SOCKET_IPPROTO_TCP, ADR(result));  //tworzy nowe gniazdo
result            :=   SysSockCOnnect(hSocket, ADR(sa), SIZEOF(sa));
numberOfSendBytes   :=   SysSockSend(hSocket, ADR(str),  30 ,0, ADR(result));
//numberOfBytes      :=   SysSockRecv(hSocket, ADR(str2), 100,0,ADR(result));
SysSockClose(hSocket);
run := FALSE;
END_IF
//recivedX := SysSockSelect(1,NULL,NULL,NULL,NULL,NULL);
//IF  recivedX>0  THEN
//numberOfBytes      :=   SysSockRecv(hSocket, ADR(str2), 100,0,ADR(result));
//END_IF

With sending data everything is ok, but I have problem with receive data.
It is a bad idea is all time use SysSockRecv function. I read that I must use SysSockSelect function.
I do not now how use it. Can you give me a hint how solve my problem ?