02-26-2004
I guess, the question is "How to find when the peer has closed its connection?"
There is a simple solution to find out when the other end of the socket has closed.
When the server reads from a closed socket, the read() call returns 0. This indicates that the client has terminated its connection.
10 More Discussions You Might Find Interesting
1. IP Networking
Requirements:
A server program should read a file and send the message to the client . if the file is not there, then switch to the receive part of the same program and receive any messages from the socket. If no messages to receive then switch to send part of the program to... (2 Replies)
Discussion started by: Rajeshsu
2 Replies
2. UNIX for Dummies Questions & Answers
I have true64 Unix running and there a scales in the sytem which connect thru a com-server to the network. they have their own IP-address and are communicating over port 8000. when I telnet to the com-servers and the print function of the scale is executed I can see the data coming.
I need to know... (1 Reply)
Discussion started by: albinhess
1 Replies
3. Programming
Please tell me according to C/C++ socket programming; how client can check whether server is running or not during TCP communication. (1 Reply)
Discussion started by: mansoorulhaq
1 Replies
4. Programming
Hi,
I am new to using threads in C++ though I have been wkring on C++ for past 1.5 years...I want to write a TCP server that serves multiple client connections...to start off..i have been working on a simple tcp echo server trying to understand how threads work....
this is my server code:
... (5 Replies)
Discussion started by: deepti_v25
5 Replies
5. IP Networking
We have a NAS application which can be accessed by both HTTP and HTTPS connections.
The issue we are facing is that the tcp server instance that initiates the HTTP access dies after a few hours of inactivity(the NAS application was kept idle for around 10 hours). However, the tcpserver that... (1 Reply)
Discussion started by: swatidas11
1 Replies
6. Programming
Hello @ all,
I hope you can give me some advice :b:
I will be following code for a tcp server and doStuff () function, the
clients treated. From some point, I have several identical
clients (zombies, I think), the same records in the database
write. Has anyone an explanation? What can I... (1 Reply)
Discussion started by: yumos
1 Replies
7. Programming
I made a program and now I need to make it concurrent.
Can someone pls help me do this ?
The code is this:
#include <sys/types.h>
#include <sys/socket.h>
#include <sys/time.h>
#include <netinet/in.h>
#include <errno.h>
#include <unistd.h>
#include <stdio.h>
#include <string.h>... (4 Replies)
Discussion started by: Johnny22
4 Replies
8. Solaris
Hi,
I am having a solaris server. I want to start a dummy TCP listner on UNIX OS on a specific port can anyone please let me know the process.
IP ADDRESS: 123.123.123.123
Port: 8010 (1 Reply)
Discussion started by: mayank2211
1 Replies
9. UNIX for Dummies Questions & Answers
I am trying to send json messages to a port on a linux server from a remote server running a .net program. I have one implementation running with successful incoming messages to port 1514. I tried to replicate the same thing but just to another port but cannot get it to work as I get the following... (3 Replies)
Discussion started by: unienewbie
3 Replies
10. Solaris
I have problem with oracle solaris 10 running on oracle sparc T4-2 server.
Os information: 5.10 Generic_150400-03 sun4v sparc sun4v
Output from tcpstat.d script
TCP bytes: out outRetrans in inDup inUnorder
6833763 7300 98884 0... (2 Replies)
Discussion started by: insatiable1610
2 Replies
LEARN ABOUT NETBSD
getpeereid
GETPEEREID(3) BSD Library Functions Manual GETPEEREID(3)
NAME
getpeereid -- get the effective credentials of a UNIX-domain peer
LIBRARY
Standard C Library (libc, -lc)
SYNOPSIS
#include <sys/types.h>
#include <unistd.h>
int
getpeereid(int s, uid_t *euid, gid_t *egid);
DESCRIPTION
The getpeereid() function returns the effective user and group IDs of the peer connected to a UNIX-domain socket. The argument s must be a
UNIX-domain socket (unix(4)) of type SOCK_STREAM on which either connect(2) has been called, or one returned from accept(2) after bind(2) and
listen(2) have been called. If non-NULL, the effective used ID is placed in euid, and the effective group ID in egid.
The credentials returned to the accept(2) caller are those of its peer at the time it called connect(2); the credentials returned to the
connect(2) caller are those of its peer at the time it called bind(2). This mechanism is reliable; there is no way for either side to influ-
ence the credentials returned to its peer except by calling the appropriate system call (i.e., either connect(2) or bind(2)) under different
effective credentials.
One common use of this routine is for a UNIX-domain server to verify the credentials of its client. Likewise, the client can verify the cre-
dentials of the server.
IMPLEMENTATION NOTES
On NetBSD, getpeereid() is implemented in terms of the LOCAL_PEEREID unix(4) socket option.
RETURN VALUES
The getpeereid() function returns the value 0 if successful; otherwise the value -1 is returned and the global variable errno is set to indi-
cate the error.
ERRORS
The getpeereid() function fails if:
[EBADF] The argument s is not a valid descriptor.
[ENOTSOCK] The argument s is a file, not a socket.
[ENOTCONN] The argument s does not refer to a socket on which connect(2) have been called nor one returned from listen(2).
[EINVAL] The argument s does not refer to a socket of type SOCK_STREAM, or the kernel returned invalid data.
SEE ALSO
connect(2), getpeername(2), getsockname(2), getsockopt(2), listen(2), unix(4)
HISTORY
The getpeereid() function appeared in NetBSD 5.0.
BSD
August 8, 2007 BSD