套接字编程中非法查找的可能原因

Probable reasons for Illegal seek in socket programming

本文关键字:查找 编程 非法 套接字      更新时间:2023-10-16

在发送数据时收到以下错误:

发送:29-Illegal找

请解释可能的原因。我是套接字编程的新手。提前谢谢。

CHAR datasend[200];
    DOUBLE64 fTime=0.0;
    LONG32 sent_bytes=0;
    while(TRUE)
    {
            memset(datasend,0,200);
            fTime=getTime();
            sprintf(datasend,"0=%.0lf ",fTime);
            sent_bytes = send ( isockfd, datasend, strlen(datasend),0);
            logDebug1("Pulse is %s and data bytes is %d",datasend,strlen(datasend));
            if(sent_bytes <= 0)
            {
                    logPError("send");
                    logTimestamp("Closing socketn");
                    close(isockfd);
                    return NULL;
            }
            sleep(25);
    }

由于中间的logDebug1调用,您没有解释正确的错误

  • 你有一个返回值为<= 0的send可能还有一个可以检查的errno
  • 您打印的东西(logDebug1) 可能会击败errno
  • 你做一些perror来解释被破坏的errno

你要做的是检查是否sentBytes < 0 perror立即,然后可能打印更多调试的东西,如果你想。