I use raspberry with tcp socket client to receive data, each message is 93030 bytes fixed. Because the TCP socket, the message are divided in small chunk. To make sure to received full message, I make in the function TcpReceiveData with while loop.
it when well but after 20 mins or more later, receive straight error with raspberry TCP socket, see picture. after problem occurred, i login raspberry codesys, the program is in stop mode(halt).
is there anybody can tell me where are the problem.
// TCP client main programIFbInitTHEN  (*RegisterCallbacks                        *)  RegisterCallbacks();  bInit:=FALSE;  bActive:=TRUE;END_IFIFbActiveTHEN    IFdiSocket=SOCKET_INVALIDTHEN    diSocket:=TcpClientOpenSocket(uiPort,stDestIPAddress);  ELSE    bConnected:=TRUE;    dataRecv:=FALSE;    (*----------------------------------------------------------------------*)    (*  Receive                  *)    (*----------------------------------------------------------------------*)  REPEAT            diReceived:=TcpReceiveData(diSocket,PtrRecvData,LenRecvData,100);      IFdiReceived>0THEN        diReceived:=0;        dataRecv:=TRUE;      END_IF            UNTIL   diReceived<=0    END_REPEAT;    IFdiReceived<0THEN(*Problemoccured*)      bConnected:=FALSE;      CloseSocket(ADR(diSocket));    END_IF  END_IFEND_IF
//FUNCTIONTcpReceiveData:DINTIFSocketIsReadable(diSocket,diTimeout)THENÂ Â WHILE(tempRecValue<diDataSize)DOÂ Â Â Â temp:=SysSockRecv(diSocket,pbyData+[b]tempRecValue[/b],diDataSize,0);Â Â Â Â tempRecValue:=tempRecValue+temp;Â Â END_WHILEÂ Â Â Â TcpReceiveData:=tempRecValue;Â Â Â Â IFTempRecvalue>0THENÂ Â Â Â TempRecvalue:=0;Â Â END_IFÂ Â Â Â Â Â IFTcpReceiveData<=0THENÂ Â Â Â TcpReceiveData:=TcpReceiveData-1;Â Â END_IFEND_IF
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
stablex hat geschrieben:
I use raspberry with tcp socket client to receive data, each message is 93030 bytes fixed. Because the TCP socket, the message are divided in small chunk. To make sure to received full message, I make in the function TcpReceiveData with while loop.
it when well but after 20 mins or more later, receive straight error with raspberry TCP socket, see picture. after problem occurred, i login raspberry codesys, the program is in stop mode(halt).
is there anybody can tell me where are the problem.
//TCPclientmainprogramIFbInitTHEN
  (*RegisterCallbacks                        *)
  RegisterCallbacks();
  bInit:=FALSE;
  bActive:=TRUE;END_IFIFbActiveTHEN
    IFdiSocket=SOCKET_INVALIDTHEN
    diSocket :=TcpClientOpenSocket(uiPort, stDestIPAddress);
  ELSE
    bConnected:=TRUE;
    dataRecv:=FALSE;
    (*----------------------------------------------------------------------*)
    (*  Receive                  *)
    (*----------------------------------------------------------------------*)
  REPEAT
     Â
      diReceived:=TcpReceiveData(diSocket, PtrRecvData, LenRecvData, 100);
      IFdiReceived>0THEN
        diReceived:=0;
        dataRecv:=TRUE;
      END_IF
     Â
      UNTIL   diReceived<=0
    END_REPEAT;
    IFdiReceived<0THEN(*Problemoccured*)
      bConnected:=FALSE;
      CloseSocket(ADR(diSocket));
    END_IF
  END_IFEND_IF
//FUNCTIONTcpReceiveData : DINTIFSocketIsReadable(diSocket, diTimeout)THEN
  WHILE(tempRecValue<diDataSize)DO
    temp:=SysSockRecv(diSocket, pbyData+[b]tempRecValue[/b], diDataSize, 0);
    tempRecValue:=tempRecValue+temp;
  END_WHILE
 Â
  TcpReceiveData:=tempRecValue;
 Â
  IFTempRecvalue>0THEN
    TempRecvalue :=0;
  END_IF
   Â
  IFTcpReceiveData<=0THEN
    TcpReceiveData:=TcpReceiveData-1;
  END_IFEND_IF
Hi, I'm working on a similar project. I have a raspberry in which I need to run a TCP server where I will receive messages from clients by sockets. I can not get it to work properly, have you managed to get it to work properly? Do you have more information on the server?
Thank you very much.
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
I use raspberry with tcp socket client to receive data, each message is 93030 bytes fixed. Because the TCP socket, the message are divided in small chunk. To make sure to received full message, I make in the function TcpReceiveData with while loop.
it when well but after 20 mins or more later, receive straight error with raspberry TCP socket, see picture. after problem occurred, i login raspberry codesys, the program is in stop mode(halt).
is there anybody can tell me where are the problem.
Hi, I'm working on a similar project. I have a raspberry in which I need to run a TCP server where I will receive messages from clients by sockets. I can not get it to work properly, have you managed to get it to work properly? Do you have more information on the server?
Thank you very much.