Sockets problems

    This site uses cookies. By continuing to browse this site, you are agreeing to our Cookie Policy.

    • Sockets problems

      Since i didnt see a Network section in the programing forum i'll just post here :0.

      Anyways i've got a fairly good understanding about sockets and everything and i'm making my own classes (much smaller then Mr Mikes) to handle just basic communications with them.

      I'm making a small chat program to learn a little more about sockets but i've run into a small problem. I dont really understand who or what calls the accept() command. Does it need to be in some kind of loop or something so that when something finnaly does connect it will be able to accept it. Or is it something you can just call once somewhere in the code.

      I believe the majority of my code should be fine i think except this one issue because i know the server is listening for a connection i just cant connect to it from my client. I've tested using telnet to connect to my server and its able to gain some kind of connection however, as far as i'm concerned this only proves the server is listening on the correct ip/port.

      Secondly, i'm running the server and client on the same computer... problem?
      - Brian Wight
    • RE: Sockets problems

      There's an example of that in the Teapots source code - did you get that working?
      Mr.Mike
      Author, Programmer, Brewer, Patriot
    • I dont belive the source for teapot wars uses accept. Im not sure why accept is used just yet, but its probably for a different setup.

      I found a good gamedev article for using it tho [ gamedev.net/reference/articles/article1059.asp ] and the help [ windowssdk.msdn.microsoft.com/en-us/library/ms741394.aspx ], more good stuff [ sockets.com/winsock.htm ] and one more example that uses unix [ netbook.cs.purdue.edu/code/code30_2.htm ]
    • very cool, this answers my question very well thanks stellar.

      I havent looked at the teapot code although the the code in the book is sufficiant for a gameing situation I like to start with just the basics and build up from there so i have a better understanding of whats going on. Theres just too much to involved in the example in the book to understand the basics imo. Anyways i think i understand it now.
      - Brian Wight
    • Whoops - you're right - Teapot source uses select()...accept() is the synchronous version.
      Mr.Mike
      Author, Programmer, Brewer, Patriot