Unix Programming - Socket Programmnig (Wait data, WAIT)

This is Interesting: Free IT Magazines  
Home > Archive > Unix Programming > May 2006 > Socket Programmnig (Wait data, WAIT)





You are viewing an archived Text-only version of the thread. To view this thread in it's original format and/or if you want to reply to this thread please [click here]

Author Socket Programmnig (Wait data, WAIT)
nori

2006-05-19, 7:15 pm

I'm working on a server for a basic chat room. The trouble is I cannot
for the life of me figure out how to make it so that the data is not
sent to every user until the sender is done typeing. What happins is
you can see what the person is typeing as they type it and if you are
typing at the same time it turns into a jumbled mess. I have tried a
few ways to fix this but I couldn't get it and I kindof ran out of
ideas so I figured I'd bring my question here. Thanks.
Nori

P.S. TCP/IP protocol if it wasn't obvious enough

nori

2006-05-19, 7:15 pm


nori wrote:
> I'm working on a server for a basic chat room. The trouble is I cannot
> for the life of me figure out how to make it so that the data is not
> sent to every user until the sender is done typeing. What happins is
> you can see what the person is typeing as they type it and if you are
> typing at the same time it turns into a jumbled mess. I have tried a
> few ways to fix this but I couldn't get it and I kindof ran out of
> ideas so I figured I'd bring my question here. Thanks.
> Nori
>
> P.S. TCP/IP protocol if it wasn't obvious enough


I forgot the most imortant part XD. I/m writting this in C.
Nori

Chris Friesen

2006-05-19, 7:15 pm

nori wrote:
> I'm working on a server for a basic chat room. The trouble is I cannot
> for the life of me figure out how to make it so that the data is not
> sent to every user until the sender is done typeing.


Store the text into a local buffer until you see the "\n" character,
then send it all at once.

Chris
nori

2006-05-19, 7:15 pm

I can't I'm not writting a client: I'm letting users use telnet. I
need some way to process it just on the server.
Nori

Chris Friesen wrote:
> nori wrote:
>
> Store the text into a local buffer until you see the "\n" character,
> then send it all at once.
>
> Chris


Karl Malbrain

2006-05-19, 7:15 pm


nori wrote:[vbcol=seagreen]
> I can't I'm not writting a client: I'm letting users use telnet. I
> need some way to process it just on the server.
> Nori
>
> Chris Friesen wrote:

He means: have the SERVER store the text in server buffers until the
server receives the '\n' character.

Your client code is going to have to wait until it transmits the '\n'
character before displaying inbound messages from the server.

karl m

nori

2006-05-19, 7:15 pm

I really don't know how to go about this. Can you help a little more.
Thanks
Nori

Karl Malbrain wrote:
> nori wrote:
>
> He means: have the SERVER store the text in server buffers until the
> server receives the '\n' character.
>
> Your client code is going to have to wait until it transmits the '\n'
> character before displaying inbound messages from the server.
>
> karl m


Mark Rafn

2006-05-19, 7:15 pm

>> nori wrote:
[vbcol=seagreen]
>Chris Friesen wrote:

nori <noridotjabi@gmail.com> wrote:[vbcol=seagreen]
>I can't I'm not writting a client: I'm letting users use telnet. I
>need some way to process it just on the server.


Does Chris's suggestion not work on the server? Have it buffer each client's
input until end of line, and then send the entire line to all the other
clients.
--
Mark Rafn dagon@dagon.net <http://www.dagon.net/>
Karl Malbrain

2006-05-19, 7:15 pm

nori wrote:[vbcol=seagreen]
> I really don't know how to go about this. Can you help a little more.
> Thanks
> Nori
>
> Karl Malbrain wrote:

You need to keep an inbound buffer and an outbound state for each
connection your application is supporting. Do you know how to do this?

Also, please do not top-post.

karl m

Barry Margolin

2006-05-20, 1:21 am

In article <1148079326.484885.299310@g10g2000cwb.googlegroups.com>,
"nori" <noridotjabi@gmail.com> wrote:

> I really don't know how to go about this. Can you help a little more.


Probably not. If you don't understand the answers that have been given
so far, you're not ready to write this type of program.

Why are you doing this? Aren't there already enough working chat
programs?

--
Barry Margolin, barmar@alum.mit.edu
Arlington, MA
*** PLEASE post questions in newsgroups, not directly to me ***
*** PLEASE don't copy me on replies, I'll read them in the group ***
Pascal Bourguignon

2006-05-20, 7:17 am

"nori" <noridotjabi@gmail.com> writes:

> I'm working on a server for a basic chat room. The trouble is I cannot
> for the life of me figure out how to make it so that the data is not
> sent to every user until the sender is done typeing. What happins is
> you can see what the person is typeing as they type it and if you are
> typing at the same time it turns into a jumbled mess. I have tried a
> few ways to fix this but I couldn't get it and I kindof ran out of
> ideas so I figured I'd bring my question here. Thanks.
> Nori
>
> P.S. TCP/IP protocol if it wasn't obvious enough


Actually this is a nice feature to be able to see what the sender
types while he types it. iChat users seems to like it to know that
the sender is typing something and regret that it's not possible when
I use an IRC/iChat gateway :-)

But this is programming, you can implement anything you can imagine.

There was this old unix program named talk, which separated the screen
in two parts: above you could see what the remote part was typing, and
below what you were typing.

You could use ncurses, and open a new line for each of the typers.

(# is the cursor)
Initial state in the terminal of Jerry.
+------------------------------------
|Jerry: #
|
|
|
+------------------------------------

Jerry types 'H':
+------------------------------------
|Jerry: H#
|
|
|
+------------------------------------

John types 'H':
+------------------------------------
|Jerry: H#
|John: H
|
|
+------------------------------------

Jerry types 'ello':
+------------------------------------
|Jerry: Hello#
|John: H
|
|
+------------------------------------

John types 'i!':
+------------------------------------
|Jerry: Hello#
|John: Hi!
|
|
+------------------------------------

Jerry types RET:
+------------------------------------
|Jerry: Hello
|John: Hi!
|Jerry: #
|
+------------------------------------

John types ' Howdy?':
+------------------------------------
|Jerry: Hello
|John: Hi! Howdy?
|Jerry: #
|
+------------------------------------

Jerry types 'Ni':
+------------------------------------
|Jerry: Hello
|John: Hi! Howdy?
|Jerry: Ni#
|
+------------------------------------

John types RET:
+------------------------------------
|Jerry: Hello
|John: Hi! Howdy?
|Jerry: Ni#
|
+------------------------------------

Jerry types 'ce, ':
+------------------------------------
|Jerry: Hello
|John: Hi! Howdy?
|Jerry: Nice, #
|
+------------------------------------

John types: 'Goo':
+------------------------------------
|Jerry: Hello
|John: Hi! Howdy?
|Jerry: Nice, #
|John: Goo
+------------------------------------

.....



or you could just split the screen in two parts:

+------------------------------------
| Hi! Howdy?
| Goo
+------------------------------------
| Hello
| Nice, #
+------------------------------------

but this wouldn't scale as much with multiple users.

--
__Pascal Bourguignon__ http://www.informatimago.com/

"Indentation! -- I will show you how to indent when I indent your skull!"
ed

2006-05-23, 7:17 pm

On Sat, 20 May 2006 09:08:29 +0200
Pascal Bourguignon <pjb@informatimago.com> wrote:

> or you could just split the screen in two parts:
>
> +------------------------------------
> | Hi! Howdy?
> | Goo
> +------------------------------------
> | Hello
> | Nice, #
> +------------------------------------
>
> but this wouldn't scale as much with multiple users.


Wow that reminds me of two things!

1) BBS sysop/multiuser chat
2) Z cards

--
Regards, Ed :: http://www.openbsdhacker.com
just another unix hacker
:%s/Open Source/Free Software/g :: Free DNS available

Sponsored Links






Free braindumps | Software forum | Database administration forum

Copyright 2003 - 2008 webservertalk.com