blob: 895eaf3d26b423cd4319d633e852ade3d8c50278 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
|
/* ISC license. */
#include <skalibs/nonposix.h>
#include <sys/socket.h>
#include <netinet/in.h>
#include <skalibs/allreadwrite.h>
#include <skalibs/socket.h>
int socket_connected (int s)
{
struct sockaddr_in sa ;
socklen_t dummy = sizeof sa ;
if (getpeername(s, (struct sockaddr *)&sa, &dummy) == -1)
{
char ch ;
fd_read(s, &ch, 1) ; /* sets errno */
return 0 ;
}
return 1 ;
}
|