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
4 answers

Easiest form of process communication in Scala

What I want to do: I want to add communication capabilities to a couple of applications (soon to be jar libraries for Java) in Scala, and I want to do it in the most painless way, with no Tomcat, wars, paths for GET requests, RPC servers, etc. What…
jmora
  • 491
  • 3
  • 14
11
votes
4 answers

Raw Sockets on Android

I want to create an application that runs on Android and uses Raw Sockets. I see there isn't any raw socket support in the java.net.* or the android.net.* libraries. Are raw sockets possible on Android?
Jim
  • 141
  • 1
  • 1
  • 5
11
votes
2 answers

How to know if the client has terminated in sockets

Suppose, I have a connected socket after writing this code.. if ((sd = accept(socket_d, (struct sockaddr *)&client_addr, &alen)) < 0) { perror("accept failed\n"); exit(1); } How can I know at the server side that client has exited. My whole…
shadyabhi
  • 16,675
  • 26
  • 80
  • 131
11
votes
3 answers

Maximum buffer length for sendto?

How do you get the maximum number of bytes that can be passed to a sendto(..) call for a socket opened as a UDP port?
epatel
  • 45,805
  • 17
  • 110
  • 144
11
votes
3 answers

Sync Vs. Async Sockets Performance in .NET

Everything that I read about sockets in .NET says that the asynchronous pattern gives better performance (especially with the new SocketAsyncEventArgs which saves on the allocation). I think this makes sense if we're talking about a server with many…
Michael Covelli
  • 2,113
  • 4
  • 27
  • 41
11
votes
3 answers

Can boost::asio only receive full UDP datagrams?

I am working on a UDP server built with boost::asio and I started from the tutorial customizing to my needs. When I call socket.receive_from(boost::asio::buffer(buf), remote, 0, error); it fills my buffer with data from the packet, but, if my…
Kjir
  • 4,437
  • 4
  • 29
  • 34
11
votes
2 answers

Socket Server Example with Swift

I tried to make an example of simple socket server. Build and run successfully. However it doesn't work well. Client couldn't connect to this server. How to solve this problem? I need your help, thanks. import Foundation let BUFF_SIZE =…
stevelee
  • 121
  • 1
  • 1
  • 3
11
votes
2 answers

Live audio via socket.io 1.0

As from socket.io website Binary streaming Starting in 1.0, it's possible to send any blob back and forth: image, audio, video. I'm now wondering, if this couldn't be the solution for something I'm trying to achieve recently. I'm actually looking…
ango
  • 361
  • 1
  • 3
  • 6
11
votes
1 answer

Using sockets in Swift like in Java

If I wanted to connect to a server, in Java I would open a Socket and initialize it with port and host address, then retrieve the input/output streams and read/write whatever I want. In Swift I'm having hard time doing so since it's not built that…
johni
  • 5,342
  • 6
  • 42
  • 70
11
votes
1 answer

why can't i bind ipv6 socket to a linklocal address

#include #include #include #include #include void error(char *msg) { perror(msg); exit(0); } int main(int argc, char *argv[]) { int sock, length, fromlen, n; struct…
Haiyuan Zhang
  • 40,802
  • 41
  • 107
  • 134
11
votes
1 answer

AcceptTcpClient vs AcceptSocket

I want to write a simple multi threaded server-client application and I've stumbled on those two while creating tcplistenr public void serverListenr { int MessageLength=0; TcpListener peerListener =…
LordTitiKaka
  • 2,087
  • 2
  • 31
  • 51
11
votes
5 answers

Socket Protocol Fundamentals

Recently, while reading a Socket Programming HOWTO the following section jumped out at me: But if you plan to reuse your socket for further transfers, you need to realize that there is no "EOT" (End of Transfer) on a socket. I repeat: if a socket…
Justin Ethier
  • 131,333
  • 52
  • 229
  • 284
11
votes
10 answers

PHP Post data with Fsockopen

I am attempting to post data using fsockopen, and then returning the result. Here is my current code:
Joseph Robidoux
  • 351
  • 2
  • 6
  • 13
11
votes
1 answer

Transfer Socket from one Activity to another

I am trying to transfer Socket attribute from one Activity to another but i can not use Intent.putExtra() method. socket = new Socket("10.0.0.9", port); i = new Intent(getBaseContext(), MainActivity.class); i.putExtra("mysocket", socket); How i can…
Greenvein
  • 117
  • 1
  • 7
11
votes
3 answers

How can I code a server/client video and audio streaming application?

I have to create a client/server system to stream video and audio. It would be very simple. Like youtube style. The server should attend clients providing a list of medias first and waiting the choice of each client to start streaming the media.…
soneangel
  • 621
  • 3
  • 10
  • 22