UNIX Socket FAQ

A forum for questions and answers about network programming on Linux and all other Unix-like systems

You are not logged in.

  • Index
  • » Threads
  • » TCP sockets as inter-thread signalling mechanism

#26 2008-05-19 05:41 PM

Kolenka
Member
Registered: 2008-05-15
Posts: 9

Re: TCP sockets as inter-thread signalling mechanism

Offline

#27 2008-05-19 07:08 PM

mlampkin
Administrator
From: Sol 3
Registered: 2002-06-12
Posts: 911
Website

Re: TCP sockets as inter-thread signalling mechanism


"The only difference between me and a madman is that I'm not mad."

Salvador Dali (1904-1989)

Offline

#28 2008-05-19 07:28 PM

Kolenka
Member
Registered: 2008-05-15
Posts: 9

Re: TCP sockets as inter-thread signalling mechanism

Offline

#29 2008-05-19 07:36 PM

mlampkin
Administrator
From: Sol 3
Registered: 2002-06-12
Posts: 911
Website

Re: TCP sockets as inter-thread signalling mechanism

Oops... I didn't realize your message was 'self contained'... my bad... :)


Michael


"The only difference between me and a madman is that I'm not mad."

Salvador Dali (1904-1989)

Offline

#30 2008-05-19 07:57 PM

Kolenka
Member
Registered: 2008-05-15
Posts: 9

Re: TCP sockets as inter-thread signalling mechanism

Offline

#31 2008-05-19 08:12 PM

mlampkin
Administrator
From: Sol 3
Registered: 2002-06-12
Posts: 911
Website

Re: TCP sockets as inter-thread signalling mechanism

Yeah - that is one catch using the select setup... having to force an EINTR / similar against the select to get it to pop back out when you have data to send... and trying to 'cluster' the adds so you didn't interrupt select too much...

Btw - they did add the aio_ stuff in POSIX... and it provides the same sort of functionality...

The caveat being some impls ( Linux - though this may have changed in new releases ) it actually caused a new thread to be created at the kernel level each time a socket was added... so while faster than a regular select or poll - it did still have some extraneous overhead...


Michael


"The only difference between me and a madman is that I'm not mad."

Salvador Dali (1904-1989)

Offline

#32 2008-05-19 10:15 PM

Kolenka
Member
Registered: 2008-05-15
Posts: 9

Re: TCP sockets as inter-thread signalling mechanism

Hmm, I may not even have the aio_ functions on my platform. I can't tell.

Either way, kqueue seems to fit my needs a bit better. Data is not constantly streaming back and forth on each socket (rather, it is sent in small 1KB bursts every so often, anywhere from 1 second to minutes between packets, since it is based on the telnet protocol), and so when the connection count gets high, iterating over an event list and using a hash map to get connection state objects for each event will probably win out as being more efficient.

Offline

#33 2008-05-20 05:35 AM

mlampkin
Administrator
From: Sol 3
Registered: 2002-06-12
Posts: 911
Website

Re: TCP sockets as inter-thread signalling mechanism

Ah... was kinda flashing over the kqueue bit... so a BSD platform I assume?

If thats the case... then yeah - aio_ is not available except as an add-on ( module )... and as I understand it there may be / have been problems with it...

Btw - and not quite off topic...

Have you ever looked at the thttpd source code ?  Its a single threaded model BUT if you are looking at alternative to select(...) and cross compatability in general... it provides a great minimalist view of ( some of ) the various alts across platforms...

It may not help you in your particular project... but still might be worth a peek...


Michael


"The only difference between me and a madman is that I'm not mad."

Salvador Dali (1904-1989)

Offline

#34 2008-05-20 05:43 PM

Kolenka
Member
Registered: 2008-05-15
Posts: 9

Re: TCP sockets as inter-thread signalling mechanism

Offline

#35 2008-05-20 10:29 PM

i3839
Oddministrator
From: Amsterdam
Registered: 2003-06-07
Posts: 2,239

Re: TCP sockets as inter-thread signalling mechanism

Objective-C works fine on other platforms too, only problem could be that you're using Apple specific libraries.

It should be easy to adapt C or C++ code to Objective-C too.

Offline

#36 2008-05-20 10:54 PM

Kolenka
Member
Registered: 2008-05-15
Posts: 9

Re: TCP sockets as inter-thread signalling mechanism

Offline

#37 2008-05-21 01:23 AM

i3839
Oddministrator
From: Amsterdam
Registered: 2003-06-07
Posts: 2,239

Re: TCP sockets as inter-thread signalling mechanism

Then looking at thttpd source code is even better cause that one is actually ported to multiple platforms, e.g. using epoll on linux and kqueue on BSD.

Offline

  • Index
  • » Threads
  • » TCP sockets as inter-thread signalling mechanism

Board footer

Powered by FluxBB