socket system call can not succedd right after application crash.


 
Thread Tools Search this Thread
Top Forums Programming socket system call can not succedd right after application crash.
# 1  
Old 08-03-2009
socket system call can not succedd right after application crash.

hello all,

I have developed a server application in C for ulinux kernel 2.6.It works very fine; creating a socket, binding it to a port, listening for incoming sockets and accepting them ,all finish without any error.
But there is a problem regarding application crash.After an intentionally termination of the application(Ctrl+C) or the application crash( by whatever reason it might be ) , when i run the application for the next time -right after application ending-, the socket creation stage fails for about 10" or more.After a while, the socket creation will succeed and everything starts normally.My question is why the socket creation cannot proceed?Is it because of still opened sockets from clients? it is because of underlying OS mechanism?
# 2  
Old 08-03-2009
It's a socket thing, you'll have to tell the OS that the socket may be used more than once. A nice explanation of socket programming and the associated options can be found here (Main page)

Also, it might be a good idea to set up a signal handler for SIGINT, SIGTERM, ..., which cleans up the workspace (close sockets, free() memory, ...) if your program dies.
Login or Register to Ask a Question

Previous Thread | Next Thread

9 More Discussions You Might Find Interesting

1. HP-UX

Sudden application crash in servers

Hi, This weekend there was a sudden application crash in the server. I did not know where to start to investigate the problem, so I first looked into the /var/adm/syslog/syslog.log, and this was what I found : Dec 17 00:38:02 L28bi01 sshd: error: accept: No buffer space available Dec 17... (9 Replies)
Discussion started by: anaigini45
9 Replies

2. Red Hat

XCB crash while Video Rendering in multithreded application

I encounter the following crash on RHEL 7.0 when I run a multithreaded video rendering application using GLFW and OpenGL. OpenGL version is 2.1 and MESA version is 9.3.0 Following is the back trace of the multi-threaded program I am working on:... (0 Replies)
Discussion started by: anuachin
0 Replies

3. IP Networking

Configure a range of ports to "socket" system call

Hello ; This what i want to do : I know that in the system call #include <sys/socket.h> int bind(int socket, const struct sockaddr *address, socklen_t address_len); you can specify the local port for your socket, but im using a private library , and im sure that in that library... (0 Replies)
Discussion started by: trutoman
0 Replies

4. Programming

Client/Server Socket Application - Preventing Client from quitting on server crash

Problem - Linux Client/Server Socket Application: Preventing Client from quitting on server crash Hi, I am writing a Linux socket Server and Client using TCP protocol on Ubuntu 9.04 x64. I am having problem trying to implement a scenario where the client should keep running even when the... (2 Replies)
Discussion started by: varun.nagpaal
2 Replies

5. Programming

C++ application halts at popen system call

Hi All, My application gets hang at the popen statement in Soalris 5.8. While debugging I found that it halts at _lwp_sema_wait. After googling I have added /usr/lib/lwp in the LD_LIBRARY_PATH and now it halts at lwp_park. Please help me what I need to do to solve this issue. The application runs... (6 Replies)
Discussion started by: Amiya Rath
6 Replies

6. Programming

Problem with socket binding - "system" call

Hi, I am having an issue with using sockets. I have a program which binds to a socket and listen on it. Later I spawn a thread to handle some function. In the new thread created I need to call a shell script which executes the specified function. Here I am using a system command to call the... (5 Replies)
Discussion started by: Janardhanbr
5 Replies

7. Linux

segmentation fault in socket application

helo, i m using linux operationg system at both client and server side. Now in my application when i use ntohl() then it will give segmentation fault. now when i remove nothl(), then it works fine. can u tell me why this happen. amit (8 Replies)
Discussion started by: amitpansuria
8 Replies

8. UNIX for Dummies Questions & Answers

Which application has a TCP socket open

If I do a netstat -a I can see all the sockets currently open, is there a way that I can tell which application is holding open these sockets ? (3 Replies)
Discussion started by: murphyboy
3 Replies

9. Linux

Making Socket System Call From Linux Kernel Module?

Hi Everyone! How can we make a socket() system call from a linux module executing in kernel space? If any one knows, kindly tell me. It will be great. I want to use the socket interface in linux kernel space for sending raw packets over the network. Hamayun (0 Replies)
Discussion started by: mian_m_hamayun
0 Replies
Login or Register to Ask a Question