Questions tagged [sockaddr-in]
29 questions
7
votes
1 answer
Why am I receiving 67 code from QOSStartTrackingClient method?
I am receiving error code 67 from the code below, which means ERROR_BAD_NET_NAME.
Why is it happening? How can I fix it?
SOCKADDR address;
strcpy_s(address.sa_data, "8.8.8.8");
address.sa_family = AF_INET;
if (!QOSStartTrackingClient(QoSHandle,…

Matin Lotfaliee
- 1,745
- 2
- 21
- 43
4
votes
2 answers
How to legally use type-punning with unions to cast between variations of struct sockaddr without violating the strict aliasing rule?
POSIX intends pointers to variations of struct sockaddr to be castable, however depending on the interpretation of the C standard this may be a violation of the strict aliasing rule and therefore UB. (See this answer with comments below it.) I can,…
user4385532
4
votes
2 answers
sockaddr.sin_port = 1337 doesn't match the "real" opened port
I am trying to make a very simple server that accept a connection.
int sock, serv;
struct sockaddr_in in_sock;
serv = socket(AF_INET, SOCK_STREAM, 0);
in_sock.sin_addr.s_addr = 0;
in_sock.sin_port = 1337;
in_sock.sin_family = AF_INET;
bind(serv,…

user96649
- 471
- 1
- 5
- 22
4
votes
1 answer
What does zero sockaddr_in mean in SCNetworkReachabilityCreateWithAddress?
tonymillion 's Reachability has
+(Reachability *)reachabilityForInternetConnection
{
struct sockaddr_in zeroAddress;
bzero(&zeroAddress, sizeof(zeroAddress));
zeroAddress.sin_len = sizeof(zeroAddress);
zeroAddress.sin_family =…

onmyway133
- 45,645
- 31
- 257
- 263
3
votes
1 answer
C++ [UDP] How to keep track of all connected(clients) socket connections on server?
my server should forward the message it received to all connected clients but my code can only send the message back to the sender.
struct User
{
char user_id[20];
string address;
struct sockaddr_in CONNECTED;
}U[8];
//USER LOGIN
…

Lozy
- 160
- 4
- 11
3
votes
2 answers
Would like to evaluate a comparison between two sockaddr_in structs
Presently I am in the midst of constructing a peer-to-peer network architecture and am at the stage of creating a receive function which will accept messages from multiple clients on the network. Essentially when the recvfrom function is called -…

Enchanter
- 117
- 1
- 10
2
votes
2 answers
C sockaddr function call for sendto?
I'm currently setting up a UDP socket for a school assignment but I can't figure out how to properly send sockaddr as a parameter into a function. The input arguments for SendData is defined the same way they are in the sendto function.
void…

Depe
- 21
- 2
2
votes
1 answer
Getting an IP address and port number from a sockaddr_in struct in Swift?
After much trial and error, and without any success, it seems I might need a bit of help on this one:
How can I get IP address and port number from a sockaddr_in in the latest version of Swift?
I saw some related questions but can't seem to find a…

Thomas De Reyck
- 23
- 5
2
votes
1 answer
sockaddr value changes unexpectedly after calling getaddrinfo()
I am programming an UDP client. I want to bind the socket to a given port on the client machine, so that the same port is always used for all sends. I get the sockaddr for the server using getaddrinfo, and I do the same to get the sockaddr which I…

joanlofe
- 3,360
- 2
- 26
- 44
1
vote
2 answers
Delete and cast. Will delete free the right amount of bytes?
Will delete free the right amount of bytes ?
unique_ptr up = make_unique();
// or unique_ptr up( new sockaddr_in ); ???
/*
Some stuff
sockaddr and sockaddr_in are two different types of…

Markus Fischer
- 29
- 2
1
vote
1 answer
how to provide custom IP to sockets in C?
How can I give a custom ip to my program, I've built a chat app, not the whatsapp, jus cui based simple chat app, coz imma beginner, I've used inet_addr() function, but it says can't assign ip, it only allows localhost IPs(127.0.0.1 to 127.0.0.254),…

BossySmaxx
- 37
- 7
1
vote
4 answers
Sockaddr union and getaddrinfo()
I'm writing a UDP socket program which is provided an address from the command line.
To make sending and writing easier, I'm using getaddrinfo to convert the address to a sockaddr struct: either sockaddr_in or sockaddr_in6. Now I understand that I…

m_highlanderish
- 499
- 1
- 6
- 16
1
vote
1 answer
getsockname returns -1, errno is EBADF?
The program runs up to the getsockname where the return is -1 and errno is 9 (EBADF, bad file descriptor). However, the code instrumented in Android app goes well.
void sysLibCSendHookHandler(CPUState* env, int isStart){
if(isStart){
int fd =…

user8246901
- 11
- 2
1
vote
2 answers
bind() - how to call bind() multiple times on the same socket
I use bind() on an address to which I have set port value equal to 0. I know that in this way, it is bind a random port to the address. But I want that only port with value x such that (x >= 0 && x <= 1023) || (x >= 49152) were choosen, but I…

user7836391
- 41
- 1
- 4
0
votes
0 answers
Problems with pointers to a struct sockaddr_in in C
I came across some problems when accessing a struct sockaddr_in* (socket C lib type).
Considering the following function:
void f(struct sockaddr_in* in){
/* Some networking operations. */
in->sin_addr.s_addr = htonl(INADDR_ANY);
in->sin_port =…

FueledByPizza
- 5
- 5