f



sockets, events, and threads

Hello -
I am coding a client/server app using sockets.  I set the server socket descriptor to non-blocking, as well as the clients after accept().  As of right now, my code is event-driven.

My question is:  I am using event-driven code, and since all my sockets are non-blocking, would spawning threads for each accept() or read() be more efficient? 

Thanks
David
0
David
6/25/2003 1:08:26 PM
comp.unix.programmer 10848 articles. 0 followers. kokososo56 (350) is leader. Post Follow

1 Replies
1000 Views

Similar Articles

[PageSpeed] 33

>>> David Hill wrote:

DH> My question is:  I am using event-driven code, and since all my sockets are non-blocking, would spawning threads for each accept() or read() be more efficient? 

http://www.kegel.com/c10k.html


-netch-
0
Valentin
6/26/2003 6:04:13 AM
Reply:

Similar Artilces:

Socket
Hi, I have started with socket programmation and well no problem since now. But now i want to thread connections for the server and I got stuck in the topic of threads. Has someone here experience in how to use threads and how they work? Perhaps somebody can send me some code so that i will finally solve my problem. Thank you! Have a nice day, Christophe <christophe.anthon@gmail.com> wrote in message news:1116848417.054125.18670@g44g2000cwa.googlegroups.com... > Hi, > I have started with socket programmation and well no problem since now. > But now i want to thread connectio...

Threads, Events and Sockets
I am writing a program that will use threads, events and sockets. I want to make sure I understand the interactions of those three so that I can get it right. I have three objects - A, B and C - each of them running in their own thread (let's call them Ta, Tb, Tc), blocking on a socket read. All of them have a reference to the _same_ dictionary wrapped in a class to make it thread-safe. They all have registered interest in any changes made to the dictionary. One of them - say A - gets a change request from it's TCP/IP client. It makes a change to the dictionary which in ...

Socket programmation with threads
Hi, I have started with socket programmation and well no problem since now. But now i want to thread connections for the server and I got stuck in the topic of threads. I think in this group some guys can help me about how to use threads in socket programmation. I read some sites, but well.. no luck. Can perhaps somebody send me some code which simply explain how to use threads or perhaps someone here has already programmed sockets with threads and could mail me some scripts. Thank you! Have a nice day, Christophe christophe.anthon@gmail.com wrote: > Hi, > I have...

Thread and Sockets: pass Socket-Id to Thread
Hi! Similar to other questions in the last days, I have a server-application that accepts requests, and then should open a new thread for every request. First, I tried using the thread low-level stuff, now I encapsuled those in a class. My problem is, that the socket-"accept()" returns a socket id. When I pass this socket-id to my thread, I cannot access the socket without having an error. I checked, but even the value in the variable storing the socket id is the same, but nevertheless, only in my main-program accesses to the socket will succeed. Some code: ...

Unix sockets and threads
Hello, can somebody explain me (or give a reference to some documentation) how a standard unix sockets behaves in case it is accessed from the context of different threads ? Some background: I have some private socket implementation. In this implementation a socket is bound to the thread that has created the socket. Now I want to line-up this with the standard unix socket bahavior. I will make my questions more clear using some scenarios: Scenario 1: Thread A is blocked on a recvfrom call while thread B is executing the same code. What will happen with thread B ? Will it be blocked on a mute...

Organizing threads, sockets, and events...
--=-ej4wTnhLZbHDJU2Qg5j6 Content-Type: text/plain Content-Transfer-Encoding: 7bit I have been working on a client/server app using wxWidgets 2.6.0. My application is a client that may need to talk to multiple servers concurrently. I've tried two different architectures and both seem to work well, I'm just wondering if anyone can comment on merits and problems with either scheme. In the first scheme, I create a single thread and use socket events to deal with each server. I have a single GUI thread that happens to get socket events too. This method works well, but I ha...

Threads, signals and sockets (on UNIX)
Hi all, I have a Python program (on UNIX) whose main job is to listen on a socket, for which I use the SocketServer module. However, I would also like it to be sensitive to signals received, which it isn't if it's listening on the socket. ("signals can only be received between atomic actions of the python interpreter", presumably - and control will not return to Python unless something appears on the socket). Does anyone have a tip of a good way to do this? I can of course put the SocketServer in a thread and call signal.pause() in the main thread, but this falls down when ...

Event handling for sockets in thread
I've tried to look for this topic in documentation wx2.8.0 and wxForum, but I have not found a satisfiable answer. So I'd like to ask you for a little help... 1) Is it correct to derive own event handler from wxEvtHandler and wxThread and handle events from sockets in secondary (non GUI) thread? 2) Is then possible to post events from secondary to main thread and from main to secondary thread? Thanks for any answer Petr Chladek pchladek@retia.cz --------------------------------------------------------------------- To unsubscribe, e-mail: wx-users-unsubscribe@...

Need help with a simple UNIX sockets server based on IO::Socket::UNIX
Hi. I've tried to create a simple client + server that communicate through a unix socket. As with all socket servers, it has a loop where it waits for connections: while ($client = $sock->accept()) { # handle client here } The problem is that $sock->accept() is returning undef on each alternate client connection with error "No child processes". I made this temporary workaround that does work but of course I must be screwing up somewhere else: while ($client = $sock->accept() || $client = $sock->accept()) { # handle client here } I hope someone can help or pr...

RE: Event handling for sockets in thread
Hi Petr PC> 1) Is it correct to derive own event handler from wxEvtHandler and wxThread PC> and handle events from sockets in secondary (non GUI) thread? It's not needed because you create a new thread for every connection. The whole handling for this connection (communication, lost connection etc.) can be done with the methods implemented within the wxSocketClient and wxSocketBase. I remember that someone has built Events for non GUI but normaly event are only available to GUI application (list: please correct me!) PC> 2) Is then possible to post events from secondary...

Problems mixing IDLE events and SOCKET/other events. (events dropped?)
Hello. I've written a program using wxwindows and it shows similar problems under windows and linux both, so I think that I'm just missing something that may be difficult to find int he docs or something because I've looked and looked and I can't seem to figure it out. I combined the opengl sample, with the socket sample and the splitter sample (I'm trying to make a game with wxwindows). I'm doing everything by hand and no gui-builders were used. The problem is that I seem to be dropping an event here and there. My app uses OpenGL to spin an object usin...

Re: Event handling for sockets in thread #3
OK, is there at least some possibility for simultaneous waiting for socket events (for example wxSocket::WaitForRead(), wxSocket::Read()...) and some "events" from other thread (for example wxCondition::Wait() ) Petr --------------------------------------------------------------------- To unsubscribe, e-mail: wx-users-unsubscribe@lists.wxwidgets.org For additional commands, e-mail: wx-users-help@lists.wxwidgets.org ...

Socket event priority, threads and idle state
Hi, I need some advice on the subject. I am using wxWidgets for displaying measurement data. Initially, I received the data trough RS232, I used the CTB package, in the idle loop I checked for new incoming data and sometimes (using a timer) refreshed the display. Now I am receiving the data through Ethernet and I am using sockets. The measurement device sends packages in adjustable time periods and the task is to receive and process them and also to display the updated content. The same model (that of RS232) works also in this case until the time period is adjusted below cca....

Re: Event handling for sockets in thread #2
Hi, thanks for your answers. I try to specify my reasons for using event handling in a secondary thread: 1) I prefer events before blocked operations :) - I think it's more universal and in addition code for threaded and nonthreaded application is very similar 2) It's a possibility to handle socket events and my events from other threads at the same time. I don't want use blocked Read() with timeout and test if there's any event from other threads, because of I need to handle events very fast. Petr --------------------------------------------------------...

Web resources about - sockets, events, and threads - comp.unix.programmer

AC power plugs and sockets - Wikipedia, the free encyclopedia
AC power plugs and sockets are devices that allow electrically operated equipment to be connected to the primary alternating current (AC) power ...

Ratcheting-Socket-Wrench-22156-480x360 - Flickr - Photo Sharing!
Free Photos – 3/8-Inch Ratcheting Socket Wrench / Chrome Socket Wrench /Repair and Fix Tool kits More photos and details about possible copyright ...

Mitch Robinson lied to Carlton about incident that left him with a broken eye socket
Mitch Robinson lied to Carlton officials when asked why he had suffered a broken eye socket during a scuffle in the early hours of Sunday morning. ...

Brisbane Broncos forward Alex Glenn facing six weeks on sideline with fractured eye socket
Wayne Bennett ranks Brisbane fullbacks as Justin Hodges injury leaves Broncos with fifth choice rookie

ConnectSense Smart Outlet lets Siri control two HomeKit Wi-Fi wall sockets, USB charge iPads
... of iPhone , iPad , and IPod Touch . What do you think? Discuss "ConnectSense Smart Outlet lets Siri control two HomeKit Wi-Fi wall sockets, ...

ASRock Rack Announces EP2C612D24 and 4L: Dual Socket Haswell-EP with 24 DDR4 Slots
... 16GB UDIMMs, this allows for a maximum of 384GB, although moving up to RDIMM, LRDIMMs or 64GB NVDIMMs pushes the max to 1.5TB in a dual socket ...

Windows Server 2016 moving to per core, not per socket, licensing
... until the second half of next year, is going to shake up the way Microsoft licenses its server operating system, moving away from per socket ...

Cool Chart of the Week: Solar Socket Parity In California, Australia, Germany, Italy, & Netherlands
I forget now how I ran across this chart, but it’s a nice one. It shows that residential solar PV power hit socket parity (aka grid parity) in ...

Dell Aims Four-Socket Server at Modern Database Hardware Needs
Launches x86 PowerEdge servers in bid to carve out more high-end server market share Read More

Video: Socket To Me! Nitwit At ‘Hand To God’ Tries To Charge Phone On Set
... on a performance of Hand To God at Broadway ’s Booth Theatre a few days ago, this patron leapt onstage and tried to plug his phone into a socket ...

Resources last updated: 1/25/2016 8:56:38 PM