Thread: Winsock - Asynchrnonous Server problems

  1. #1
    30 Helens Agree neandrake's Avatar
    Join Date
    Jan 2002
    Posts
    640

    Winsock - Asynchrnonous Server problems

    I'm messing around with asynchronous sockets, and I'd like to make a simple echo server. I have it setup all fine and people can connect and stuff, but when any client sends data to my server, I want the server to send back to every connected user, including the one that originally sent the data. I'm having a little trouble keeping track of clients and such with this problem. Has anyone ever made an asynchronous socket? I don't think I need to do multi-threading to solve this (I thought the idea of asynchronous was to eliminate multi-threaded socket stuff). Does anyone have an idea of how to set this up? Thanks.
    Environment: OS X, GCC / G++
    Codes: Java, C#, C/C++
    AOL IM: neandrake, Email: neandrake (at) gmail (dot) com

  2. #2
    30 Helens Agree neandrake's Avatar
    Join Date
    Jan 2002
    Posts
    640
    I forgot to mention something else. The send() function takes a SOCKET as the first param. Is the socket the one that was created for listening? Or do I need to go through a loop of all connected sockets to use as the first parameter?
    Environment: OS X, GCC / G++
    Codes: Java, C#, C/C++
    AOL IM: neandrake, Email: neandrake (at) gmail (dot) com

  3. #3
    End Of Line Hammer's Avatar
    Join Date
    Apr 2002
    Posts
    6,231
    When all else fails, read the instructions.
    If you're posting code, use code tags: [code] /* insert code here */ [/code]

  4. #4
    30 Helens Agree neandrake's Avatar
    Join Date
    Jan 2002
    Posts
    640
    SOCKET is a typedef of type int, by the way, and I strongly recommend you explicitly use int instead of SOCKET, for portability.
    Why?
    Asynchronous sockets aren't available in *nix, right?

    Thanks vVv for clarifying the first param. I'll add a reply with the results, whether they worked or not.
    Environment: OS X, GCC / G++
    Codes: Java, C#, C/C++
    AOL IM: neandrake, Email: neandrake (at) gmail (dot) com

  5. #5
    30 Helens Agree neandrake's Avatar
    Join Date
    Jan 2002
    Posts
    640
    Oh, cool, I didn't know that. But at the moment, I'm not looking to make my software portable. It's mainly for personal use right now.
    Environment: OS X, GCC / G++
    Codes: Java, C#, C/C++
    AOL IM: neandrake, Email: neandrake (at) gmail (dot) com

  6. #6
    Registered User johnnie2's Avatar
    Join Date
    Aug 2001
    Posts
    186
    Are you utilizing asynchronous sockets with window notifications?
    "Optimal decisions, once made, do not need to be changed." - Robert Sedgewick, Algorithms in C

  7. #7
    30 Helens Agree neandrake's Avatar
    Join Date
    Jan 2002
    Posts
    640
    Yes, I'm using windows messages to use asynchronous sockets.
    Environment: OS X, GCC / G++
    Codes: Java, C#, C/C++
    AOL IM: neandrake, Email: neandrake (at) gmail (dot) com

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Server Architecture
    By coder8137 in forum Networking/Device Communication
    Replies: 2
    Last Post: 01-29-2008, 11:21 PM
  2. winsock server question?
    By kocho in forum Windows Programming
    Replies: 2
    Last Post: 02-02-2006, 01:52 PM
  3. SMTP Server Not Working
    By (TNT) in forum Networking/Device Communication
    Replies: 1
    Last Post: 07-15-2003, 05:33 AM
  4. Simple Server problems...
    By Unregistered in forum C++ Programming
    Replies: 0
    Last Post: 10-20-2001, 08:51 PM
  5. Socket Problems
    By (TNT) in forum Windows Programming
    Replies: 4
    Last Post: 08-18-2001, 06:59 AM