04-09-2009
connect() socket API
Is there any relation between the connect() socket API and the TCP's Transmission Control Block.
Also how does connect detect that a socket is in use i.e., EADDRINUSE
10 More Discussions You Might Find Interesting
1. Programming
Hello All,
I have a problem using connect(...) function in C++. I am using SSH from my windows system to connect it to linux server. The program works fine if I run it directly in Linux machine but I need it to run through windows machine.
The function returns -1 and so my program terminates.
... (3 Replies)
Discussion started by: smdhd3
3 Replies
2. UNIX for Advanced & Expert Users
Hi,
I was porting ipv4 application to ipv6; i was done with TCP transports. Now i am facing problem with SCTp transport at runtime.
To test SCTP transport I am using following server and client socket programs. Server program runs fine, but client program fails giving Invalid Arguments for... (0 Replies)
Discussion started by: chandrutiptur
0 Replies
3. Programming
Can anyone tell what is the system API for VxWorks which is used to find GetLastError() for socket/bind failure.
I need to use it in some VxWorks application and need to call GetLastError but I'm not sure about the correct API.
Thanks in advance (1 Reply)
Discussion started by: anilgurwara
1 Replies
4. Programming
Why does this socket function only read the first 1440 chars of the stream. Why not the whole stream ? I checked it with gdm and valgrind and everything seems correct...
#include <stdio.h>
#include <stdlib.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <string.h>
#include... (3 Replies)
Discussion started by: cyler
3 Replies
5. IP Networking
I need clarification on whether it is okay to set socket options on a listening socket
simultaneously when it is being used in an accept() call?
Following is the scenario:-
-- Task 1 - is executing in a loop - polling a listen socket, lets call it 'fd', (whose file descriptor is global)... (2 Replies)
Discussion started by: jake24
2 Replies
6. UNIX for Dummies Questions & Answers
solaris client report "cannot to socket(code 25)" while trying to backup on veritas netbackup 6.5.5 server (1 Reply)
Discussion started by: EUGINIAM
1 Replies
7. Programming
will there be any unexpected results on looping connect call for a non blocking socket to determine the connection based on error code. I am getting connection unsuccessful intermittently and so wondering whether is the timeout 500 millisec not sufficient or looping connect cause any unexpected.
... (7 Replies)
Discussion started by: satish@123
7 Replies
8. Shell Programming and Scripting
Hi,
I need to call an API (GetUsageDetails)from inside a shell script which takes an input argument acct_nbr.
The output of API will be like :
<usageAccum accumId="450" accumCaptn="PM_125" inclUnits="1410.00" inclUnitsUsed="744.00" shared="true" pooled="false" prorated="false"... (1 Reply)
Discussion started by: rkrish
1 Replies
9. UNIX for Beginners Questions & Answers
I'm trying a new distro called KaliBang. After the install I noticed this error is having problems letting multiple applications I have work:
(nm-applet:3674): GConf-WARNING **: Client failed to connect to the D-BUS daemon:
Did not receive a reply. Possible causes include: the remote... (2 Replies)
Discussion started by: Azrael
2 Replies
10. Web Development
Ref:
https://itnext.io/face-api-js-javascript-api-for-face-recognition-in-the-browser-with-tensorflow-js-bcc2a6c4cf07 (0 Replies)
Discussion started by: Neo
0 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)