Questions tagged [sockets]

An endpoint of a bi-directional inter-process communication flow. This often refers to a process flow over a network connection, but by no means is limited to such. Not to be confused with WebSocket (a protocol) or other abstractions (e.g. socket.io).

In computer networking, a socket* is an endpoint of a bidirectional inter-process communication flow across an Internet Protocol-based computer network, such as the Internet.

An internet socket address is the combination of an IP address (the location of the computer) and a port (which is mapped to the application program process) into a single identity, much like one end of a telephone connection is the combination of a phone number and a particular extension. It is primarily used in the Transport Layer.

An example IPv4 socket appears as: 10.1.1.1:80

An example IPv6 socket appears as: [fe80::1]:80 (Note the brackets)

The term is believed to have originated with the Berkeley Sockets API for Unix ca. 1983.

Related tags are , , , and .

* Not to be confused with (a protocol) or other abstractions (e.g. ).

Note to programmers, especially beginners, using the socket module: A great many questions about non-working socket programs seem to be based on a common misunderstanding that is discussed and corrected in this answer as well as this one. Please take the time to read and understand that answer if you are having problems.

66255 questions
12
votes
2 answers

Socket closed exception

I wrote a simple server and client example as below . Client : Open a connection Get outputstream , write to stream and close the output stream Get inputstream and read from the stream. Getting exception at this point public class DateServer…
Abhilash
  • 377
  • 1
  • 3
  • 13
12
votes
6 answers

What is the quickest way to detect an unreachable host in Java?

I would like the fastest and most accurate function boolean isReachable(String host, int port) that passes the following JUnit tests under the conditions below. Timeout values are specified by the JUnit test itself, and may be considered…
grammar31
  • 2,000
  • 1
  • 12
  • 17
12
votes
2 answers

connect() with unix-domain socket and full backlog

When the listening backlog is full for STREAM unix-domain sockets, connect(2) fails on most systems with ECONNREFUSED. It would be preferable for it to return EAGAIN. The reasoning is that it is highly useful to be able to distinguish between the…
Nicholas Wilson
  • 9,435
  • 1
  • 41
  • 80
12
votes
5 answers

Setting source port on a Java Socket?

I'm very new to socket programming: Is it possible to explicitly set the the source port on a Java Socket? I am working on a client/server application in which clients could potentially be listening for replies from the server on several ports. It…
AndreiM
  • 4,558
  • 4
  • 36
  • 50
12
votes
3 answers

Check connection open or closed ?(in C in Linux)

In socket programming in Linux I need to write data in socket but I don't know socket is open or close . how to I know that socket is open and close without read ? printf("befor read%d\n", n); bzero(buffer, MAX_SIZE_BUFFER); n = read(sockfd, buffer,…
Sajad Bahmani
  • 17,325
  • 27
  • 86
  • 108
12
votes
1 answer

Checking if path is a socket in Python 2.7

What would be the best way in Python 2.7 to find out if a path is a socket? os.path has is... functions for directories, normal files and links. The stat module offers some S_IS... functions like S_ISSOCK(mode) which I used as import os,…
trapicki
  • 1,881
  • 1
  • 18
  • 24
12
votes
2 answers

Max Outgoing Socket Connections in .NET/Windows Server

I have a slightly unusual situation where I'm needing to maintain CLIENT tcp connections to another server for thousands of mobile users on my servers (basically the mobile devices connect to my middle tier server when they are able to, which…
Redth
  • 5,464
  • 6
  • 34
  • 54
12
votes
2 answers

Sending audio stream over TCP, UnsupportedAudioFileException

I have succeeded with sending and reading text and images data over TCP sockets. But I am unable to sending and reading audio stream data. sample code at server: public class ServerAudio { /** * @param args */ public static void…
mini
  • 855
  • 4
  • 15
  • 22
12
votes
3 answers

What is weblogic.socket.Muxer?

Does any of you understand what weblogic.socket.Muxer is used for in WebLogic 8.1? Often in thread dumps I see stack traces similar to this: "ExecuteThread: '0' for queue: 'weblogic.socket.Muxer'" id=20 idx=0x68 tid=26709 prio=5 alive, in native,…
Andrey Adamovich
  • 20,285
  • 14
  • 94
  • 132
12
votes
1 answer

C++ / Xcode Sockets bind() Error

When trying to process the return value (should be int) from sys/sockets.h bind(), Xcode fails to compile with the error Invalid operands to binary expression ('__bind' and 'int') It seems to be pulling the incorrect function definition for bind(),…
Calteran
  • 1,063
  • 8
  • 12
12
votes
5 answers

Storage size of sockaddr_in variable isn't known

I have a piece of code that used to work in some environment a long time ago. I'm pretty sure it was a FreeBSD machine so I got FreeBSD 8.3 and I'm trying to make this file but it's not working. When I try to compile it it complains with: f.c: In…
coconut
  • 1,074
  • 4
  • 12
  • 30
12
votes
2 answers

What is a good book/guide for socket programming in C?

Could anybody please tell me which is best guide/book/material for socket programming in C? I am reading beej's guide for network programming but it just gives an overview. Can you suggest any other books or guides?
Vijay
  • 65,327
  • 90
  • 227
  • 319
12
votes
2 answers

Python Socket Listening

All of the below mentioned is on windows machines using python 2.7 Hello, I am currently attempting to listen on a socket for data send by a remote program. This data is then printed to the screen and user input is requested that is then returned to…
Mr S
  • 458
  • 3
  • 7
  • 15
12
votes
2 answers

How many tuples are there in a connection?

Some people said that there are 4 tuples in a connection client IP address, client port number, server IP address, server port number Some said that there are 5 client IP address, client port number, server IP address, server port number,…
onmyway133
  • 45,645
  • 31
  • 257
  • 263
12
votes
2 answers

Using JMeter to test a socket

I would like to use JMeter to test an application that communicates over sockets. It is done in java. In the server I have the typical myServerSocket = new ServerSocket(1025); For every connection a thread reads and understands a line. And in…
lesolorzanov
  • 3,536
  • 8
  • 35
  • 53