Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7857539
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 2, 20262026-06-02T21:04:18+00:00 2026-06-02T21:04:18+00:00

i am programing a client/server software in Python using sockets. I have a question,

  • 0

i am programing a client/server software in Python using sockets.

I have a question, specifically for the TCP/IP and Socket models:

I am using this example of code on my server side (server side program in Python):

import socket
# Create a TCP/IP socket
server = socket.socket(socket.AF_INET, socket.SOCK_STREAM)

# Prevent from "address already in use"
server.setsockopt(socket.SOL_SOCKET, socket.SO_REUSEADDR, 1)

# Bind the socket to port
server_address = ("localhost", 5000)
server.bind(server_address)

# Listen for connections
server.listen(5)

# Wait for on incomming connection
read = connection.recv(1024)
print "Received: ",read

Everything is fine, but i have some conceptual questions:

1) How is the best practice for enable this comunication?? Do I have to setup a heartbeat traffic for the TCP/IP between the CLIENT and SERVER programs?? I saw that even i leave the client program without traffic (idle) with the server, when i come back and send another message (a lot of minutes and minutes after the connection establishing) the messages stills go. Is it normal behavior?

2) The TCP/IP stack or even the “socket module” has any kind of TIMEOUT function?!?! Who can i control lost our “timed-out” connections in Python using the socket module??

Tks for all !

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-02T21:04:19+00:00Added an answer on June 2, 2026 at 9:04 pm

    In TCP, heartbeats are not needed to keep the connection alive. Connections will live as long as both endpoints are still healthy.

    However, a heartbeat can be useful to detect failures early. Otherwise, you’ll only find out when you try to send data (or expect the other end to send data) whether the connection is still alive. In many cases, this is good enough. But for some (like an IRC application) you want to know soon after the client goes down, so you can notify others that they have been removed from the channel.

    You might be able to use the SO_KEEPALIVE socket option to send heartbeat packets automatically, but I have no experience with it. This question may be helpful.

    For timeouts, use the SO_RCVTIMEO and SO_SNDTIMEO socket options. See man 7 socket and the Python socket documentation for more.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm making an application server client using tcp sockets in c# .. The application
I am writing a client-server application using TCP Sockets. The server is written in
I'm programming a C/C++ client/server sockets application. At this point, the client connects itselfs
I have written a small client server socket application. It is a proof of
Hi all I have created server and client using blackberry java programming ,but i
I'm programming my first socket lines, and have accomplish to make a client server
When will I normally need different ports for client-server communication? (This question is for
I have developed a java client server app based on socket programming. I am
I'm programming a simple network chat with a Python server and a Java client.
I have a tcpip socket interface to a third party software app. I've implemented

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.