epoll detecting client connections


 
Thread Tools Search this Thread
Top Forums Programming epoll detecting client connections
# 1  
Old 01-10-2008
epoll detecting client connections

I've got a program running using epoll to poll activity on a listening socket. I want to be able to output a message to the terminal when the socket is connected to from the client app. It appears that epoll doesn't throw any events on the connect but only on the socket activity. Is there any way to be notified once the client connects so that I can write a banner message to the client?

Thanks...
# 2  
Old 01-14-2008
You are using DGRAM, or other stateless sockets? Otherwise you'll need to call accept() for the new tcp connection anyway and writing to the new fd at that time
is okay.

Since udp is connectionless the idea of a 'new' client is kind of strange. You could record client addresses via recvfrom and implement some kind of scheme to determine what 'new' means based on context you determine I guess.

Here's a barebones example from google without a write after accept().
http://finiteloop.org/~btaylor/etc/epoll.cc.txt
Login or Register to Ask a Question

Previous Thread | Next Thread

8 More Discussions You Might Find Interesting

1. Programming

Event driven programming / epoll / typedef union / session data array

Sorry for the “word salad” subject, but I wanted to cast a wide net for help. I've created an IP (Internet Protocol) server which serves HTTP, SMTP, and FTP requests. As you probably know, they all require creating a socket, listening on it, accepting connections, and then having a short... (3 Replies)
Discussion started by: John S.
3 Replies

2. Shell Programming and Scripting

need help in detecting errors

Hi All , I need a script to find errors in a particular and in a particular path Actually in my logs i`ve so many kinds of errors(i can even say as 100 types also).if i run the script i need to know the error (some errors can aviod ) so finally the script o/p should be a numeric... (3 Replies)
Discussion started by: radha254
3 Replies

3. Programming

epoll problem with tcp connect()

I am using epoll to manage my network connections. At the client side, the idea is to send the message upon detecting the completion of connect(). I've set up the socket to be nonblocking, then after calling of connect(), I add the socket into the epoll and wait on the event to be detected from... (0 Replies)
Discussion started by: tuesday420
0 Replies

4. UNIX for Advanced & Expert Users

epoll, sockets and threads

Hello Forum, There is a transient bug in my code which I just can't catch. Could you help please? The basic idea is this. I have a multithreaded server and two thread pools, the IO pool and Worker pool. The main server thread listens to incoming connections. When it gets one, it dispatches... (0 Replies)
Discussion started by: rij
0 Replies

5. Programming

Detecting interruptions in C

Hi. You may know how to detect when a interruption succeeded programming in C. Just like receiving a signal without blocking. Knowing when it was a keystroke (IRQ 2), or a mouse movement (12), or a disk access, etc. and getting actually for example the letter typed. Thanks a lot. (7 Replies)
Discussion started by: Ashrentum
7 Replies

6. UNIX for Dummies Questions & Answers

Detecting Second disk

Hello all, first of all, I apologise if I may ask stupid or obvious questions, but I'm new to UNIX and I think I need a little bit of help before I start gearing up :) Anyway, I have installed a Solaris 8 on a Sun machine, and it has 2 physical disks in it. However, it seems that it is only... (7 Replies)
Discussion started by: dragunu
7 Replies

7. Programming

epoll problem

I programmed simple tcp server using nonblocking sockets and epoll. But I am facing some problems. 1. I can recv from events.data.fd but I can't send any data over events.data.fd 2. When I make multiple connections at once (say 100) I get segmentation fault... What am I doing wrong? ... (1 Reply)
Discussion started by: Parahat Melayev
1 Replies

8. UNIX for Dummies Questions & Answers

detecting drives

I know that Unix is different from windows in that it needs more manual configuring but how do I get Solaris 8 (Intel version) to recognize my floppy drive and cd-rom?? I mean does it automatically detect the drives at startup and I have to mount them or do I have to create the drives somehow and... (1 Reply)
Discussion started by: eloquent99
1 Replies
Login or Register to Ask a Question