02-25-2002
In principle, all communication is 'binary'
That said, you have some options when creating a socket:
These are some protocols from a Linux book:
AF_UNIX (Is my book old, has this one gotten a new name?)
AF_INET - the one you probably want :-)
AF_ISO - Some new stuff ...
AF_NS - Xerox
Then, some socket types:
SOCK_STREAM - probably most used, connection based
SOCK_DGRAM - very intersting, can be fast on LAN
SOCK_RAW - Maybe this is the one you want?
If you build a new protocol, you may use this?
In principle, sockets are used like files:
open, read/write, close.
So, to transfer a file, you would open and write in one end, and open, read and close in the other ... but you probably have something particular in mind ...??
This is a GROSS oversimplification, does not speak about bind(), listen(), accept(), etc. - but check socket(3SOCKET), it will contain links to the other relevant calls.
Atle
10 More Discussions You Might Find Interesting
1. Programming
Dear Reader,
Is there any way to check up socket status other than 'netstatus '
Thanks in advance, (1 Reply)
Discussion started by: joseph_shibu
1 Replies
2. Programming
Hello,
I actually try to make client-server program.
I'm using SCO OpenServer Release 5.0.0 and when I try to compile my code (by TELNET) I've got this error :
I'm just using this simple code :
and I get the same error if I use :
If someone can help me,
Thanks (2 Replies)
Discussion started by: soshell
2 Replies
3. IP Networking
my system is a stand alone system... i want to try doing socket porgramming..ihave heard that this is usually done during testing...
how can i do that....? (6 Replies)
Discussion started by: damn_bkb
6 Replies
4. Programming
Hi ,
I'm facing the following problem in socket programming.
My structure is
struct {
int i;
char *str;
}samp;
I'm creating the pointer to this structure and assigning the value to the structure members and send via the socket to the another process.
The receiver process when... (7 Replies)
Discussion started by: arunviswanath
7 Replies
5. Programming
i m using sockets for setting up a connection between a server and a client.
When the clients gets connected to the server, its ip is conveyed to the server through one of the predefined structures in c library...
i save this ip address in an array....1st client's ip address goes to the zeroth... (1 Reply)
Discussion started by: abmxla007
1 Replies
6. UNIX for Dummies Questions & Answers
in c socket programming, how can I send and received on the same port? (7 Replies)
Discussion started by: Peevish
7 Replies
7. UNIX for Dummies Questions & Answers
in socket programming how can i : Create for example 3 blank files, namely: server, client, network
•Server: act as servers/provider, will receive all requests from different client
•Client: requesters
•Network: middle-layer of communication between server & client
any tips or... (6 Replies)
Discussion started by: kedah160
6 Replies
8. Programming
Hi everyone,
I'm new to this forum. I'm working on new project for last few days and this forum already helped me on
couple of occasions. I don't have any prior experience with network programming so I'll appreciate any advise given.
I'm trying to do the following:
1. open user... (2 Replies)
Discussion started by: _thomas
2 Replies
9. Homework & Coursework Questions
Use and complete the template provided. The entire template must be completed. If you don't, your post may be deleted!
1. The problem statement, all variables and given/known data:
I am working on a hands on project. We are creating a script for a corporate phone list. The project I am... (2 Replies)
Discussion started by: SarahBelle7858
2 Replies
10. Ubuntu
HI
Can anyone provide me with codes for file transfer server to client or vice versa?
Also please explain how to compile those programs in ubuntu terminal as i am totally new to socket programming.
Thanks (1 Reply)
Discussion started by: mayhemtrigger
1 Replies
tcp(4p) tcp(4p)
Name
tcp - Internet Transmission Control Protocol
Syntax
#include <sys/socket.h>
#include <netinet/in.h>
s = socket(AF_INET, SOCK_STREAM, 0);
Description
The TCP protocol provides reliable, flow-controlled, two-way transmission of data. It is a byte-stream protocol used to support the
SOCK_STREAM abstraction. TCP uses the standard Internet address format and, in addition, provides a per-host collection of ``port
addresses''. Thus, each address is composed of an Internet address specifying the host and network, with a specific TCP port on the host
identifying the peer entity.
Sockets utilizing the TCP protocol are either ``active'' or ``passive''. Active sockets initiate connections to passive sockets. By
default TCP sockets are created active; to create a passive socket the system call must be used after binding the socket with the system
call. Only passive sockets can use the call to accept incoming connections. Only active sockets can use the call to initiate connections.
Passive sockets can ``underspecify'' their location to match incoming connection requests from multiple networks. This technique, termed
``wildcard addressing'', allows a single server to provide service to clients on multiple networks. To create a socket that listens on all
networks, the Internet address INADDR_ANY must be bound. The TCP port can still be specified at this time. If the port is not specified,
the system will assign one. Once a connection has been established, the socket's address is fixed by the peer entity's location. The
address assigned the socket is the address associated with the network interface through which packets are being transmitted and received.
Normally, this address corresponds to the peer entity's network.
TCP supports one socket option that is set with and tested with Under most circumstances, TCP sends data when it is presented; when out-
standing data has not yet been acknowledged, it gathers small amounts of output to be sent in a single packet, once an acknowledgement is
received. For a small number of clients, such as window systems that send a stream of mouse events that receive no replies, this packeti-
zation may cause significant delays. Therefore, TCP provides a Boolean option, TCP_NODELAY (from to defeat this algorithm. The option
level for the call is the protocol number for TCP, available from
Diagnostics
A socket operation may fail with one of the following errors returned:
[EISCONN] Try to establish a connection on a socket which already has one.
[ENOBUFS] The system runs out of memory for an internal data structure.
[ETIMEDOUT] A connection was dropped due to excessive retransmissions.
[ECONNRESET] The remote peer forces the connection to be closed.
[ECONNREFUSED] The remote peer actively refuses connection establishment (usually because no process is listening to the port).
[EADDRINUSE] An attempt is made to create a socket with a port that has already been allocated.
[EADDRNOTAVAIL] An attempt is made to create a socket with a network address for which no network interface exists.
See Also
getsockopt(2), socket(2), inet(4f), intro(4n), ip(4p)
tcp(4p)