Re: Client to connect to a chat server
- From: Mihai Osian <zzz@xxxxxxx>
- Date: Mon, 30 Oct 2006 20:22:39 +0100
Nikolaj wrote:
Hi everybody,
I have a program server that receive strings from many clients and
then send this strings to all the clients connected to him. I connect
to the server with Telnet.
But if I want to write the program client I have a problem. I have to
write code that read from keyboard a string and a code that read
strings from the server (other clients), in this way a made a chat.
But if I write this, the program stops when he has to read from the
stdandard input (keyboard) and if there are data from the server he
don't go receive them.
Also if I write code that receive data from the server, if data isn't
there, I'm wasting my time.
How can I resolve this?
Thank you very much.
Nikolaj
What you are looking for is "select" and "non-blocking sockets". Go here: http://linoleum.leapster.org and under "network programming" you will find some examples how to use it.
Hint: when you read from the console, you read from a default file-descriptor called "stdin". You can use "select" with any file descriptor (sockets are "descriptors", too).
Mihai
.
- Follow-Ups:
- Re: Client to connect to a chat server
- From: Nikolaj
- Re: Client to connect to a chat server
- References:
- Client to connect to a chat server
- From: Nikolaj
- Client to connect to a chat server
- Prev by Date: Re: What is LDAP and is it useful on home network FC5?
- Next by Date: Re: Cannot connect t internal mail server
- Previous by thread: Client to connect to a chat server
- Next by thread: Re: Client to connect to a chat server
- Index(es):
Relevant Pages
|