bug-commoncpp
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Problem with TCPStream (CommonC++-1.6.1)


From: David Sugar
Subject: Re: Problem with TCPStream (CommonC++-1.6.1)
Date: Sat, 06 Oct 2001 09:32:14 -0400
User-agent: Mozilla/5.0 (X11; U; Linux i686; en-US; rv:0.9.3) Gecko/20010802

For unformatted data, you can always do a read or write stream method.

address@hidden wrote:

Hi,

i have a problem with making a simple tcp-client
for writing a IRC-bot.
Here are the only lines of my code (very short):
---------------------------------------------
   #include <iostream>
   #include <string>
   #include <cc++/socket.h>

   int main() {
        cout << "suibot" << endl;

        TCPStream mystream("localhost",6664);
        mystream << "NICK elmex\r\n";
        mystream.sync();
        while(mystream.isConnected()) {
            while(mystream.isPending(SOCKET_PENDING_INPUT, 2000)) {
                char buf[2];
                mystream.getline(buf,1);
                cout << "line:" << buf[1] << endl;
            }
            cout << "Timeout" << endl;
        }
   }
---------------------------------------------
I tested this programm with NetCat:
Console1:
----------
address@hidden: ~$ nc -l -p 6664
NICK elmex
----------
I typed in Console1:
'Foobar and Stuff'

and console2, with the client started gives:
--------------------------------
suibot
IS CON!
Timeout
Timeout
line:
line:
line:
...
--------------------------------

I am wondering. The >> operators do work. but i want
unformatted input. Think of binary data or control-characters?

I am using CommonC++ version 1.6.1
uname -a: Linux x-paste.de 2.4.9 #2 Tue Oct 2 12:26:22 CEST 2001 i586 unknown
I have a AMD K6-2 300mhz 192 MB RAM.

If something is missing, mail me.


cya






reply via email to

[Prev in Thread] Current Thread [Next in Thread]