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
1 answer

C++ send file and text via socket

Im trying to send a image using socket but I have to send the file name as well. Im using a code that i send the file but when I send the file name i receive some strange characters in client. Client: #define PORT 20000 #define LENGTH 512 int…
user1726861
12
votes
1 answer

Get IP-Address from DNS without GetHostByName

I am using GetHostByName to get the IP-Address from a Host/DNS. I also have Kaspersky Internet Security 2013 and noticed that GetHostByName gets picked by it. It seems that that my process tries to create a subkey in…
Ben
  • 3,380
  • 2
  • 44
  • 98
12
votes
2 answers

connect() returns "Operation now in progress" on blocking socket?

I have a blocking socket (at least it appears so in following code): sock = socket(AF_INET, SOCK_STREAM, IPPROTO_TCP); if (sock < 0) { ERROR("%s: error opening socket", __func__); return (RESP_ERROR); } …
Ivan Ostres
  • 155
  • 1
  • 1
  • 6
12
votes
6 answers

Sending a Dictionary using Sockets in Python?

My problem: Ok, I made a little chat program thing where I am basically using sockets in order to send messages over a network. It works great, but when I decided to take it a step further, I ran into a problem. I decided to add some encryption to…
Micrified
  • 3,338
  • 4
  • 33
  • 59
12
votes
5 answers

How to properly maintain a listening port for a long time?

I wrote this small server application in pure C that listens to incoming connections in a given port, very simple stuff. It goes with the usual socket initialization procedure, create the socket() then bind() to the port, says its a listen(), and…
Havenard
  • 27,022
  • 5
  • 36
  • 62
12
votes
5 answers

Nodejs & socket io : warn - error raised: Error: listen EADDRINUSE

I am giving a try to Node.js with socket.io Now here is my scenario i am ubuntu 12.04 user and i have folder pp on desktop inside that i am putted server file i.e app.js Here is the content var fs = require('fs') , http = require('http') …
masterofdestiny
  • 2,751
  • 11
  • 28
  • 40
12
votes
4 answers

Android : Socket - java.net.SocketException: sendto failed: EPIPE (Broken pipe)

I am trying to make connection with server using socket. The connection pipe is broken as shown below exceptions. 01-31 14:47:16.536: W/System.err(27255): java.net.SocketException: sendto failed: EPIPE (Broken pipe) 01-31 14:47:16.550:…
Rahul Baradia
  • 11,802
  • 17
  • 73
  • 121
12
votes
4 answers

Get TCP address information in ZeroMQ

I want to connect clients to a server using ZeroMQ (java bindings, jzmq), but I need the TCP information badly, for example the TCP/IP address of a client request! The problem is, for being able to announce a service in the network I need to grab…
AlexLiesenfeld
  • 2,872
  • 7
  • 36
  • 57
12
votes
1 answer

Is it safe to issue blocking write() calls on the same TCP socket from multiple threads?

Let's say I have two threads, T1 and T2. Thread T1 makes a blocking write() call on a TCP socket S to send a large buffer of bytes B1. The buffer of bytes B1 is so large that (a) the write call blocks and (b) TCP has to use multiple segments to send…
Bruno Rijsman
  • 3,715
  • 4
  • 31
  • 61
12
votes
4 answers

How to deal with network port abuse in sockets

I have a web app written in c++ using TCP/IP over standard network sockets, running on Linux. The service is open to the wild and woolly internet. Periodically I get bursts of abusive requests from spammers running automated scripts. I can detect…
Rafael Baptista
  • 11,181
  • 5
  • 39
  • 59
12
votes
2 answers

WinSock.h & WinSock2.h which to use?

Does anyone know the differences between WinSock.h and WinSock2.h . I know they don't use the same library (.lib) but I don't know if WinSock2 only adds new features or if it also improves WinSock 1 features. I am working with IP/TCP sockets and…
Antares
  • 161
  • 1
  • 2
  • 6
12
votes
1 answer

How to specify the ciphersuite to be used in SSL session

I have created a socket on port 443 as in the following line: socket = (SSLSocket) factory.createSocket(hostName, port); Then, I wanted to see the enabled ciphersuites in this socket, I used: String[]…
user1810868
  • 1,565
  • 8
  • 23
  • 30
12
votes
1 answer

Setting up an R-Server that supports asynchronous communication with clients

In short Is it possible set up an R-Server that can handle/dispatch multiple client requests in an asynchronous way? I guess I'm looking for some sort of socket communication. Or is there something even more efficient to let R talk to other…
Rappster
  • 12,762
  • 7
  • 71
  • 120
12
votes
1 answer

Why does OS X allow listening on the same TCP port twice?

I was trying to debug port allocation problems in Jenkins on OS X by listening to certain ports with netcat, which led to some weird results. In a terminal on OS X 10.8.2: $ uname -rs Darwin 12.2.1 $ nc -l 54321 Then in an second terminal: $ nc…
Christopher Orr
  • 110,418
  • 27
  • 198
  • 193
12
votes
2 answers

Deserialization exception: Unable to find assembly

I'm serializing some data like fields and custom class to create a binary data (byte array). Then I want to Deserialize it back from binary data to fields and class. But I get an exception. It would all work fine if these two methods would happen in…
Mitja Bonca
  • 4,268
  • 5
  • 24
  • 30