Re: Client to connect to a chat server



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
.



Relevant Pages

  • TidTCPServer - Maybe Off-Topic
    ... The server listen for the clients on port 12000. ... The only thing server does is to write the strings to database. ... TIdTCPServer or it handles that automatically? ...
    (borland.public.delphi.language.objectpascal)
  • Client to connect to a chat server
    ... then send this strings to all the clients connected to him. ... to the server with Telnet. ... stdandard input (keyboard) and if there are data from the server he ...
    (comp.os.linux.networking)
  • Re: socketServer questions
    ... There are currently 500 clients and potentially there ... The way it's written now, the server reads a single request, writes ... and closes the connection. ... > send strings of data to the server. ...
    (comp.lang.python)
  • socketServer questions
    ... I have written a python socketServer program and I have a few questions ... The clients are light and fast never sending more than 270 bytes of data and never connecting ... What's the proper way to handle server exceptions? ... All the strings start with x and end with y and have z in the middle. ...
    (comp.lang.python)
  • RE: Users Cant Access Documents on Server
    ... Thanks for using the SBS newsgroup. ... As well as we know, if a workstation would not access network shares, then ... Leave the Default Gateway of the internal NIC blank of the server box. ... Clients That Require SMB Signing ...
    (microsoft.public.windows.server.sbs)