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
11
votes
3 answers

Close a socket and then reopen it from the same port in .net

Well, I wonder if some one can help with a problem that I encounter.... I want to close a socket and then rerun from the same port. This is what i am doing... opening: UdpServer = new Socket(AddressFamily.InterNetwork, SocketType.Dgram,…
Jasim Khan Afridi
  • 776
  • 3
  • 15
  • 28
11
votes
6 answers

The speed of socket is 120MB/s on a computer, is it normal?

I tested the performance of transferring data from a program to another over socket on a single computer, and the speed is 120MBytes/s, is it normal? My server and client programs are both extremely simple. And my computer is AMD Athlon X2 4000+, 4G…
Freewind
  • 193,756
  • 157
  • 432
  • 708
11
votes
1 answer

Binding on privileged ports (ports < 1024) on Mac OS X 10.6

Do you know how to remove restriction on binding to ports < 1024 with a user account that is not root on Mac OS X?
Nicu B.
  • 111
  • 1
  • 4
11
votes
4 answers

Android LocalServerSocket

In android, there are two classes LocalServerSocket and LocalSocket. I think they are something like AF_LOCAL in unix socket (I am not sure it is correct or not). My question is that : Is it possible to create LocalServerSocket in Java and use a…
Bohan Lu
  • 513
  • 2
  • 6
  • 20
11
votes
1 answer

AF_PACKET equivalent under Mac OS X (Darwin)

I am trying to compile a C program on Mac OS X that uses AF_PACKET sockets and libpcap, what is the equivalent in OS X?
user198736
11
votes
8 answers

How can I send data over the internet using a socket?

I would like to send data over internet through a desktop application. I know a little bit about sockets. I have transferred the data within the LAN, but now I want to transfer the data over the internet. What is the best way to transfer both large…
Mohanavel
  • 1,763
  • 3
  • 22
  • 44
11
votes
2 answers

Error installing sockets php extension inside docker

Inside dockerfile: docker-php-ext-install sockets Gives these errors, on docker build (I used same dockerfile for days but today it appears this new error): /usr/src/php/ext/sockets/sendrecvmsg.c: In function…
John TDO
  • 111
  • 1
  • 3
11
votes
4 answers

What are some reasons NetworkStream.Read would hang/block?

MSDN documentation seems to suggest that NetworkStream.Read will always return immediately. If no data is found it returns 0. However, I have some code that is currently deployed, that only in some cases (and I haven't figured out which ones yet),…
Mark
  • 5,223
  • 11
  • 51
  • 81
11
votes
2 answers

Socket.IO 4.0.1: Get socket by id

I used const my_socket = io.sockets.connected['YnwlYH-gCKT2K9jEAAAu']; a lot. https://stackoverflow.com/a/24464450/1707015 Is it broken in 3.X and 4.0.1? $ npm list socket.io socket.io@4.0.1 $ npm list socket.io-client socket.io-client@4.0.1 #…
qräbnö
  • 2,722
  • 27
  • 40
11
votes
6 answers

in what way is java.net.Socket threadsafe?

I have a Socket that I am both reading and writing to, via BufferedReaders and BufferedWriters. I'm not sure which operations are okay to do from separate threads. I would guess that writing to the socket from two different threads at the same time…
lacker
  • 5,470
  • 6
  • 36
  • 38
11
votes
1 answer

How to abort/cancel HTTP request in Python thread?

I'm looking to abort/cancel an HTTP request in a Python thread. I have to stick with threads. I can't use asyncio or anything outside the standard library. This code works fine with sockets: """Demo for Canceling IO by Closing the…
GrantJ
  • 8,162
  • 3
  • 52
  • 46
11
votes
3 answers

Python: Non-blocking socket or Asynchronos I/O

I am new to Python and currently have to write a python socket to be run as a script that communicates with a device over TCP/IP (a weather station). The device acts as the Server Side (listening over IP:PORT, accepting connection, receiving…
Tu Hoang
  • 4,622
  • 13
  • 35
  • 48
11
votes
1 answer

Join multiple rooms at once Socket.io

I have an application where a user can get a list of chat rooms they are in, they can then click into any specific chat room they want. Currently the socket joins the room when the user clicks into a specific room and the socket leaves the room when…
Conor
  • 113
  • 1
  • 1
  • 5
11
votes
3 answers

ERROR SocketEnginePolling: Error during long poll request

let manager = SocketManager(socketURL: URL(string: "Some url")!, config: [.log(true), .compress]) var socket:SocketIOClient! var name: String? var resetAck: SocketAckEmitter? override func viewDidLoad() { super.viewDidLoad() socket =…
Shankar Thorve
  • 131
  • 2
  • 6
11
votes
2 answers

lua http socket timeout

The LuaSocket HTTP module documentation says that a timeout can be set on a HTTP connection: The following constants can be set to control the default behavior of the HTTP module: PORT: default port used for connections; PROXY: default proxy used…
ripat
  • 3,076
  • 6
  • 26
  • 38