Note that there are some explanatory texts on larger screens.

plurals
  1. POC++ Winsock Socket Error: 10038 (WSAENOTSOCK)
    primarykey
    data
    text
    <p>I have an master slave application Master running on WinXp(i7, 2.1 Ghz) and slave being a controller board. The master sends request to the slave and the slave in response send to the master the data cyclically. This data send cyclically by the slave is 1000 bytes per 0.5 msec. When the masters makes the request to send the data, on the console an error is reported.</p> <p>" Select() function error code:: 10038 ". </p> <p>This is the code for <code>WSAENOTSOCK</code>.</p> <p>This application is a single threaded application receiving the data from the slave. As from the error it seems that the socket is closed before it is checked by the select function.</p> <p>Can any one please point me in the direction ?</p> <p>:::Source Code::::</p> <pre><code>int Receive() { int rc; socklen_t cli_alen; struct timeval to; fd_set read_fd, write_fd, excep_fd; FD_ZERO(&amp;write_fd); FD_ZERO(&amp;excep_fd); sock_again: if (!_isSocketOpen) { return 0; } FD_ZERO(&amp;read_fd); FD_SET(_sock_fd, &amp;read_fd); to.tv_sec = 0; to.tv_usec = 0; cli_alen = sizeof(SOCKADDR_IN); rc = select(_sock_fd+1, &amp;read_fd, &amp;write_fd, &amp;excep_fd, &amp;to); if (rc == 0 ) { // Timeout // printf("XCP Port %d : select() timded out \n", _port); acess = 1; goto sock_again; } else if (rc == SOCKET_ERROR) { // Error LogError("XCP: select() error %d", WSAGetLastError()); closesocket(_sock_fd); return -1; } else { // Data if (!FD_ISSET(_sock_fd, &amp;read_fd)) { LogError("XCP: select() wrong socket descr"); return -1; } else { //read data rc = recvfrom(_sock_fd, (char *)_recvBuf, UDP_RECVBUFLEN, 0, (LPSOCKADDR)&amp;_saddr, &amp;cli_alen); } } } </code></pre> <p>:::: Edited ::::</p> <pre><code>int CloseUdpConnection() { if (closesocket(_sock_fd) == SOCKET_ERROR) { LogError("closesocket() error: %d", WSAGetLastError()); return -1; } _isSocketOpen = 0; LogError("successfully closed socket %s:%d", _address, _port); return 0; } </code></pre> <p>::::: Debug Trace :::::</p> <pre><code>xcpApplication.exe -i 192.168.1.100 -p 5555 c --&gt; Connecting... &lt;-- Connection established t --&gt; Setting daq signal list... Sorting daq signal list... Sorting done &lt;-- Daq signal list set d --&gt; Configuring daq lists... &lt;-- Configuration done r --&gt; Starting measurement... &lt;-- Measurement started **_sock_fd: -448997078** XCP: select() error 10038 </code></pre> <p>::::: Trace ::::</p> <pre><code>--&gt; Starting measurement... &lt;-- Measurement started _sock_fd: -1963260928 _sock_fd: 0x8afb0400 XCP: select() error 10038 </code></pre> <p>:::::: Trace ::::</p> <pre><code>xcpApplication.exe -i 192.168.1.100 -p 5555 _sock_fd: 1936 _sock_fd: 0x790 successfully opened socket 192.168.1.100:5555 --&gt; Connecting... &lt;-- Connection established t --&gt; Setting daq signal list... Sorting daq signal list... Sorting done &lt;-- Daq signal list set d --&gt; Configuring daq lists... &lt;-- Configuration done c --&gt; Connecting... &lt;-- Connection established r --&gt; Starting measurement... &lt;-- Measurement started _sock_fd: 901186560 _sock_fd: 0x35b70400 XCP: select() error 10038 </code></pre>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload