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

List:       linux-audio-dev
Subject:    Re: [linux-audio-dev] Question regarding network coding
From:       rm <async () cc ! gatech ! edu>
Date:       2002-08-31 4:18:52
[Download RAW message or body]

On Fri, Aug 30, 2002 at 11:49:32PM -0400, Ivica Bukvic wrote:
> Hi all,
> 
> I am already aware of some networking stuff, but am not sure as to how
> to make client aware that the server has finished sending the struct
> (since some values, like strings can be of different lengths, I can not
> simply just specify a fixed size of the information to be received).

you should probably tell the client how much to expect. if you are
using tcp you have to do your own framing since it's a streaming
protocol.  (in constrast, udp is a datagram based protocol).

msg: | preamble | length | type |....|

etc.  you can use the preamble to give the receiver a reasonable shot 
at resynching to the stream if something goes wrong.

> Furthermore, the only time I worked with network stuff was with
> streaming soundfiles, it seems that the process would be stuck in a loop
> until the transfer was complete. So my question is how do I make this
> networking process instantiate itself, but then let it run as a
> side-routine? Do I need to create a separate thread (or thread(s) in the
> case there are more clients) in order to have these networking processes
> running?

the basic outline for a  tcp server is 

	ssock = socket...
	bind(ssock,...)
	listen(ssock, ...)
	while (1) { 
		clientsock = accept(ssock)
		fork...
	}

where fork is either a fork proper, or pthread_create, pass the 
thread the clientsock and you should be ready to go.


here's some code and explanations:
http://world.std.com/~jimf/papers/sockets/sockets.html

you can also get the software from comer's tcp/ip books
http://www.cs.purdue.edu/homes/dec/netbooks.html


this is from memory ... someone correct me if i'm wrong.

		rob
----
Robert Melby
Georgia Institute of Technology, Atlanta Georgia, 30332
uucp:     ...!{decvax,hplabs,ncar,purdue,rutgers}!gatech!prism!gt4255a
Internet: async@cc.gatech.edu
[prev in list] [next in list] [prev in thread] [next in thread] 

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