[prev in list] [next in list] [prev in thread] [next in thread] 

List:       kde-devel
Subject:    Re: QServerSocket: connected, now what?
From:       Kevin Krammer <kevin.krammer () gmx ! at>
Date:       2002-01-29 11:24:43
[Download RAW message or body]

-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

On Tuesday, 29. January 2002 01:42, Erik Sigra wrote:
> No luck here :(
>
> I have this code in the constructor of the class Application:
>
>   server.setPort(5678);
>   server.setSocketFlags(KExtendedSocket::passiveSocket);
>   kdDebug() << "server.listen() = " << server.listen() << "\n";
>   connect(&server, SIGNAL(readyRead()), this, SLOT(readData()));

Common misconception.
The server socket is not a data socket.
The server socket waits for incomming connects and creates data sockets for 
each of them.

- -- copied from Thiago's post---
to accept a socket:
KExtendedSocket* client; // must be a pointer
server.accept(client);
- ------

The socket called client is the data socket which will generate the signals 
you're waitng for.

Summary:
Server creates server socket, which starts listening on a port
Client creates data socket, which connects to the server.
Server accepts connection and creates a data socket bound to the client's 
data socket.
ServerSocket can go back to eait for yet another connection from another 
client.

cheers,
Kevin

- -- 
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Kevin Krammer <kevin.krammer@gmx.at>
Developer at the Kmud Project http://www.kmud.de/
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.0.6 (GNU/Linux)
Comment: For info see http://www.gnupg.org

iD8DBQE8VoaCnKMhG6pzZJIRAh8FAJ48Qp0SWS6eIJEUMbAmUi9TVbiyQQCdHIG7
z4+iKsgFkxq+s8XazyTcczA=
=vpZ7
-----END PGP SIGNATURE-----

>> Visit http://mail.kde.org/mailman/listinfo/kde-devel#unsub to unsubscribe <<
[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic