Questions tagged [socklen-t]

`socklen_t` is an opaque integer type defined in `socket.h`. It is related to socket APIs.

9 questions
8
votes
2 answers

invalid conversion from int to socklen

Below is my code for Linux. I am implementing a client/server application and below is the server .cpp file. int main() { int serverFd, clientFd, serverLen, clientLen; struct sockaddr_un serverAddress;/* Server address */ struct sockaddr_un…
Andres
  • 275
  • 2
  • 6
  • 14
7
votes
1 answer

Data Type - socklen_t, sa_family_t

I'm building a simple socket web server using the sys/socket.h lib, and I came across the socklen_t and sa_family_t data types and am a bit confused on what their actual purpose is. Definition: sa_family_t - unsigned integer type. socklen_t - an…
Jordan Davis
  • 1,485
  • 7
  • 21
  • 40
6
votes
3 answers

getnameinfo specifies socklen_t

The 2nd arg for the getnameinfo prototype asks for a socklen_t type but sizeof uses size_t. So how can I get socklen_t ? Prototype: int getnameinfo(const struct sockaddr *restrict sa, socklen_t salen, char *restrict node, socklen_t nodelen,…
Neeladri Vishweswaran
  • 1,695
  • 5
  • 22
  • 40
5
votes
3 answers

Differ in signedness - warning

I don't understand my warning in gcc compiler. Warning is: warning: pointer targets in passing argument 6 of ‘recvfrom’ differ in signedness I don't know, where is a problem, I am not using signed and unsigned value. Problem is on…
staigoun
  • 75
  • 1
  • 7
2
votes
0 answers

Why does inet_ntop() use socklen_t to describe size of textual buffer?

From a recent Linux man-page: const char *inet_ntop(int af, const void *src, char *dst, socklen_t size); This function converts the network address structure src in the af address family into a character string. size describes the size of…
alk
  • 69,737
  • 10
  • 105
  • 255
1
vote
2 answers

error C2065: 'socklen_t' : undeclared identifier

The whole error is: Error 1 error C2065: 'socklen_t' : undeclared identifier c:\users\richard\documents\visual studio 2010\projects\server\server\server.cpp 41 1 Server This is the problematic line: int iRcvdBytes=recvfrom(iSockFd, buff,…
Richard Knop
  • 81,041
  • 149
  • 392
  • 552
0
votes
1 answer

In sockets, why do I have to use sizeof(addr) in connect() instead of using (socklen_t)&addr like in accept()?

I'm experimenting with sockets in C++, and I don't understand why in the accept() function the last parameter is: socklen_t *addr_len And I can do this: accept(m_sock, (struct sockaddr *)&addr, (socklen_t *)&addr); But in the connect() function…
user15747807
0
votes
1 answer

Trying to implement TCP echo server in C

Was trying to implement a TCP echo server with C, and came across this code while searching the web and was trying to compile it. It shows some error related to socket.h #include #include #include #include…
akbharath
  • 3
  • 5
-1
votes
1 answer

Why is the address length argument is pointer in the function accept() and recv()?

int accept(int sockfd, struct sockaddr *addr, socklen_t *addrlen); I don't understand why the addrlen argument is pointer, but not socklen_t ?
John_ABC
  • 17
  • 1