1

I have developed Linux socket server connection which is working fine.

When start from terminal it start from listening from client. but when I close terminal it stops listening.

I need to continue even though the terminal closed by user from started.

how can I run server socket application in Linux as background process?

am run using ./a.out 8888(portno)

again i will connect error will come (connection refused)

now what do i?

Thank You.

2 Answers 2

2

On terminal execute the script ending with &.

A task can usually be started and run as a background task by putting a '&' at the end of the command line.

Check this:

Linux Background Job

Sign up to request clarification or add additional context in comments.

5 Comments

yes but run in first time only. after that error in connection for connection refused .
You have to control your program to keep exceptions and keep always running, with & your program will run in background but you have to keep it alive.
background process is alive the problem is port number connection refused
Ok, but this is a programming issue, the question was about running processes on background so you can close the terminal. Check that that port is not being used by other application and check the socket is starting properly. Which language did you used to program this script
You need to set socket option SO_REUSEADDR. When your program exists abnormally socket goes into time_wait state and it will be there for couple of minutes. If you try to bind same port again you will get error in bind.
0

You can use nohup to keep the program running if the Terminal is closed:

nohup ./a.out 8888 &

(Standard output/error will be written to nohup.out instead of the Terminal.)

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.