Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. C / C++ / MFC
  4. Problems with sockets (win32)

Problems with sockets (win32)

Scheduled Pinned Locked Moved C / C++ / MFC
sysadminalgorithmsquestion
3 Posts 2 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • J Offline
    J Offline
    justin223
    wrote on last edited by
    #1

    Hello I've got a client/server application that sends small packets 10-50 bytes. The server, running win2000, uses IOCP and WSARecv + WSASend. The client uses an ownmade socket class also using WSARecv/WSASend and overlapped IO. Both the client/server waits for a Read, handles it and invoked WSARecv again. WSASend is only invoked when something is waiting in the outbuffer. Serverside: The first two transactions are handled ok (both transactions are sent at the same time and is recieved with the same WSARecv). But the second transaction, sent a couple of seconds later, will not be read by the server. The IOCP function gets called by the WSARecv but 0 bytes read are reported. ClientSide: After the last send I do a WSAGetOverlappedResult and it reports that the bytes were sent. I've tried to disable the nagle algorithm and setting SO_SNDBUF + SO_RCVBUF to 0 in the client. I've also tried to set SO_SNDBUF/SO_RCVBUF to zero in the server. client log: Socket(3)(Connect): WSAConnect() OK! Socket(3)(Read): WSARecv Socket(3)(Read): pending read... Send Trans: 0 Send Trans: 2 Socket(3)(Send): New data triggered. Socket(1)(Send): WSASend Socket(3)(Send): Write completed Socket(3)(Read): Read completed. Socket(2)(Read): WSAGetOverlappedResult Recieve, Trans: 0 Socket(2)(Read): 71/71 bytes handled Socket(3)(Read): WSARecv Socket(1)(Read): Completed directly 14 bytes Recieve, Trans: 2 Socket(2)(Read): 14/14 bytes handled Socket(3)(Read): WSARecv Socket(3)(Read): pending read... Send Trans: 3 Socket(3)(Send): New data triggered. Socket(1)(Send): WSASend Socket(3)(Send): Write completed Socket(3)(Read): Read completed. Socket(2)(Read): WSAGetOverlappedResult <- returns 0 bytes serverlog: prio: 1 client: 4 Connect from 127.0.0.1:1201 prio: 1 client: 4 Read -> Incomming bytes: 29 prio: 3 client: 4 Recieve, Trans: 0 prio: 3 client: 4 Send, Trans: 0 prio: 1 client: 4 Send -> WSASend prio: 2 client: 4 Send ->Sent 71/71 bytes. (flags: 0) prio: 3 client: 4 Recieve, Trans: 2 prio: 3 client: 4 Send, Trans: 2 prio: 1 client: 4 Send -> WSASend prio: 2 client: 4 Send ->Sent 14/14 bytes. (flags: 0) prio: 2 client: 4 Read -> 29/29 bytes handled prio: 1 client: 4 Read -> WSARecv prio: 2 client: 4 Read -> Pending read inited prio: 0 client: 4 0 bytes read! prio: 1 client: 4 Read -> aborting, dead or shutting down... What am I doing wrong?

    J 1 Reply Last reply
    0
    • J justin223

      Hello I've got a client/server application that sends small packets 10-50 bytes. The server, running win2000, uses IOCP and WSARecv + WSASend. The client uses an ownmade socket class also using WSARecv/WSASend and overlapped IO. Both the client/server waits for a Read, handles it and invoked WSARecv again. WSASend is only invoked when something is waiting in the outbuffer. Serverside: The first two transactions are handled ok (both transactions are sent at the same time and is recieved with the same WSARecv). But the second transaction, sent a couple of seconds later, will not be read by the server. The IOCP function gets called by the WSARecv but 0 bytes read are reported. ClientSide: After the last send I do a WSAGetOverlappedResult and it reports that the bytes were sent. I've tried to disable the nagle algorithm and setting SO_SNDBUF + SO_RCVBUF to 0 in the client. I've also tried to set SO_SNDBUF/SO_RCVBUF to zero in the server. client log: Socket(3)(Connect): WSAConnect() OK! Socket(3)(Read): WSARecv Socket(3)(Read): pending read... Send Trans: 0 Send Trans: 2 Socket(3)(Send): New data triggered. Socket(1)(Send): WSASend Socket(3)(Send): Write completed Socket(3)(Read): Read completed. Socket(2)(Read): WSAGetOverlappedResult Recieve, Trans: 0 Socket(2)(Read): 71/71 bytes handled Socket(3)(Read): WSARecv Socket(1)(Read): Completed directly 14 bytes Recieve, Trans: 2 Socket(2)(Read): 14/14 bytes handled Socket(3)(Read): WSARecv Socket(3)(Read): pending read... Send Trans: 3 Socket(3)(Send): New data triggered. Socket(1)(Send): WSASend Socket(3)(Send): Write completed Socket(3)(Read): Read completed. Socket(2)(Read): WSAGetOverlappedResult <- returns 0 bytes serverlog: prio: 1 client: 4 Connect from 127.0.0.1:1201 prio: 1 client: 4 Read -> Incomming bytes: 29 prio: 3 client: 4 Recieve, Trans: 0 prio: 3 client: 4 Send, Trans: 0 prio: 1 client: 4 Send -> WSASend prio: 2 client: 4 Send ->Sent 71/71 bytes. (flags: 0) prio: 3 client: 4 Recieve, Trans: 2 prio: 3 client: 4 Send, Trans: 2 prio: 1 client: 4 Send -> WSASend prio: 2 client: 4 Send ->Sent 14/14 bytes. (flags: 0) prio: 2 client: 4 Read -> 29/29 bytes handled prio: 1 client: 4 Read -> WSARecv prio: 2 client: 4 Read -> Pending read inited prio: 0 client: 4 0 bytes read! prio: 1 client: 4 Read -> aborting, dead or shutting down... What am I doing wrong?

      J Offline
      J Offline
      John M Drescher
      wrote on last edited by
      #2

      One thing to make sure with IOCP is that you should make sure the same socket is not serviced by more than one thread at a time otherwise you will have problems. John

      J 1 Reply Last reply
      0
      • J John M Drescher

        One thing to make sure with IOCP is that you should make sure the same socket is not serviced by more than one thread at a time otherwise you will have problems. John

        J Offline
        J Offline
        justin223
        wrote on last edited by
        #3

        John M. Drescher wrote: One thing to make sure with IOCP is that you should make sure the same socket is not serviced by more than one thread at a time otherwise you will have problems. Why? Im using CriticalSections..

        1 Reply Last reply
        0
        Reply
        • Reply as topic
        Log in to reply
        • Oldest to Newest
        • Newest to Oldest
        • Most Votes


        • Login

        • Don't have an account? Register

        • Login or register to search.
        • First post
          Last post
        0
        • Categories
        • Recent
        • Tags
        • Popular
        • World
        • Users
        • Groups