Menu

demos: tcp, tcpthread

Help
Anonymous
2000-05-04
2000-05-05
  • Anonymous

    Anonymous - 2000-05-04

    I apologize for the basic question, but am trying CC++ for the first time.
    I have some background in socket programming (at Winsock API level), but need a hint about the usage of the samples.

    In tcp or tcpthread, I change IP addr and get the application to "listen", i.e. in while(server.isPending(..)) block.  Especially in tcpthread, it appears that the TCPSession is the client that would be attaching to the existing server instance.  The necessary handshaking does not appear to take place.  I have built the libs/apps with gnu in Linux and msdev in winNT with same results.  Any hints?

     
    • Sean Cavanaugh

      Sean Cavanaugh - 2000-05-05

      <A HREF="http://www.dimensionalrift.com/zhlt/sandbox/code/">Check this out</A>

      This is the socket section of my console app, which currently functions in windows.  The original code is C, so there is a lame interface complete with some global variables to start up either a socket server or a client.

      SocketThreads.cpp is the C/CPP gateway, The two local classes are just background threads to keep other work going (you could ignore them).

      NetvisSession.h  contains 4 classes,
      The first is a generic packet class which is used to translate my apps packets into something that can be queue'd up (class Packet)
      The second is a simple TCPSocket derived class which is technically not necessary in a simple app.
      The third is a TCPSession derived class, which does the majority of the work, which includes sending and receiving all data.  Both the clients and the server use this class.
      The fourth is a Thread derived class, which is the socket server (and only runs on the server) which just listens for connections and fires off new TCPSession objects on the server.

      The threading control kind of sucks, my main app just signals the threads they are 'done' and should kill themselves in a timely manner.  It works though :)

      There is code elsewhere which calls NetvisSession::SendPacket to fill the outbound queue, as well as to handle the incoming packets

       
      • Sean Cavanaugh

        Sean Cavanaugh - 2000-05-05

        Sourceforge munged the hyperlink but if you correct it, it will work.

         
      • Sean Cavanaugh

        Sean Cavanaugh - 2000-05-05

        I almost forgot: there is a call to a nonexistant Socket:: function which I added in my local copy of CommonC++, called getErrorTextFromNumber, I had just added a static function to Socket:: to return the sockerror_t codes in Text format so I could display them for debugging use.

         

Log in to post a comment.

Want the latest updates on software, tech news, and AI?
Get latest updates about software, tech news, and AI from SourceForge directly in your inbox once a month.