Discerning sockets using asynchronous

This is a discussion on Discerning sockets using asynchronous within the Networking/Device Communication forums, part of the General Programming Boards category; Im using winsock and I'm using asynchronous sockets. I am going to have multiple clients each on different sockets so ...

  1. #1
    C++ Enthusiast jmd15's Avatar
    Join Date
    Mar 2005
    Location
    MI
    Posts
    532

    Discerning sockets using asynchronous

    Im using winsock and I'm using asynchronous sockets. I am going to have multiple clients each on different sockets so I declared an array of sockets for my clients. My problem is discerning what socket is performing the action. My server will get an FD_READ message with my defined WM_SOCKETMESSAGE but I don't know which client is sending the data so I don't know which socket to recv from!? Any help is appreciated.
    Trinity: "Neo... nobody has ever done this before."
    Neo: "That's why it's going to work."
    c9915ec6c1f3b876ddf38514adbb94f0

  2. #2
    carry on JaWiB's Avatar
    Join Date
    Feb 2003
    Location
    Seattle, WA
    Posts
    1,972
    I believe that wParam will hold the socket for an FD_READ message, but I can't seem to find an msdn page to back me up...
    "Think not but that I know these things; or think
    I know them not: not therefore am I short
    Of knowing what I ought."
    -John Milton, Paradise Regained (1671)

    "Work hard and it might happen."
    -XSquared

  3. #3
    C++ Enthusiast jmd15's Avatar
    Join Date
    Mar 2005
    Location
    MI
    Posts
    532
    I've tried the WPARAM, but what would I need to change it to? Like is there some macro to convert it? I couldn't just do this:
    Code:
    recv(clientSockets[wParam],.....);
    I've tried that and it stays at 0. Hmm...
    Trinity: "Neo... nobody has ever done this before."
    Neo: "That's why it's going to work."
    c9915ec6c1f3b876ddf38514adbb94f0

  4. #4
    Registered User
    Join Date
    Sep 2004
    Location
    California
    Posts
    3,265
    You don't change it to anything, the WPARAM value is your socket.
    Code:
    recv((SOCKET)wParam,...);

  5. #5
    C++ Enthusiast jmd15's Avatar
    Join Date
    Mar 2005
    Location
    MI
    Posts
    532
    Thank you bithub, once again you've nailed my question.
    Trinity: "Neo... nobody has ever done this before."
    Neo: "That's why it's going to work."
    c9915ec6c1f3b876ddf38514adbb94f0

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. question about asynchronous sockets
    By pode in forum Networking/Device Communication
    Replies: 8
    Last Post: 12-27-2004, 02:33 PM
  2. Asynchronous sockets
    By dpro in forum Networking/Device Communication
    Replies: 4
    Last Post: 12-20-2004, 06:53 PM
  3. Asynchronous Sockets Class
    By neandrake in forum Networking/Device Communication
    Replies: 0
    Last Post: 11-17-2003, 09:42 AM
  4. Starting window sockets
    By _Cl0wn_ in forum Windows Programming
    Replies: 2
    Last Post: 01-20-2003, 11:49 AM
  5. Asynchronous sockets?
    By SyntaxBubble in forum Windows Programming
    Replies: 2
    Last Post: 02-04-2002, 09:33 PM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21