c++ - getpeername sa_data -


I want to get the socket IP address associated with my server socket. I've included my code.

sa_data "[xxx.xxx.xxx.xxx"] does not return four types of [14]. Instead, it is [11] [1] [xxx] [xxx] [xxx] [xxx] [] [] [] [] [] [] [] [] [] [] [] [] [] ... [] [] [] [] ... [] returns. Can anyone help?

  int initial results; Four sandmus [1024]; Four receive messages [1024]; WSADATA WSAData; Connector signal; IDR * results; Socket SunSocket; Socket client socket; Zoramori (and signs, shapes (signs)); Signal AE _Family = AF_INET; Signal AIICTIP = SOCK_STREAM; Signal E_protocol = IPPROTO_TCP; Signal AI_flags = AI_PASSIVE; While (1) {Initial results = WSAS startup (MacWorld (2,2), and WSAData); If (initial results! = 0) {cout & lt; & Lt; "WSA Start Up Failed."; } Initial results = Getadienfo (faucet, port number, and signal, and result); If (initial results! = 0) {cout & lt; & Lt; "Fetching address information failed."; WSACleanup (); } ListenSocket = Socket (Results-> AI_Family, Results-> AI_Socketype, Results-> Ai_Protocol); If (ListenSocket == INVALID_SOCKET) {cout & lt; & Lt; "Socket initialization failed."; WSACleanup (); } Initial Result = Tie (Sunsocket, Results-> AI_ADR, (Int) Results-> AI_Enderlane); If (initial result == SOCKET_ERROR) {cout & lt; & Lt; "Bind Failed" & lt; & Lt; Port number; Listenersocket; ListenSocket = INVALID_SOCKET; WSACleanup (); } Initial Result = Listen (Sunsocket, Somexian); If (initial result == SOCKET_ERROR) {cout & lt; & Lt; "Listen failed." & Lt; & Lt; Port number; Listenersocket; ListenSocket = INVALID_SOCKET; WSACleanup (); } ClientSocket = Acceptable (SunSource, Faucet, Faucet); If (ClientSketch == INVALID_SOCKET) {cout & lt; & Lt; "Accepting the socket failed." & Lt; & Lt; Port number; WSACleanup (); } Testosterone test; Int a = sizeof (test); Cout & lt; & Lt; "Getpeername () Return value:" & lt; & Lt; Getpeername (clientSocket, & amp; test, & amp; a) & lt; & Lt; Endl; Cout & lt; & Lt; "Test.sa_data:" & lt; & Lt; Test.sa_data; StartReceive (ReceivMessage, ClientSocket); Strcpy (SendMessage, "Congratulations! You have successfully transferred some data to Gda."); Send Start (Send Message, ClientSket); StartSend (portnumber, ClientSocket); Initial Result = Shutdown (ClientSketk, SD_SEND); If (initial result == SOCKET_ERROR) {cout & lt; & Lt; "Shut down failed." & Lt; & Lt; Port number; Closesocket (ClientSocket); WSACleanup (); } Closet (ClientSket); Listenersocket; WSACleanup (); } Second and third arguments allow you to get that information without any additional calls;  

Binary Address to String Representation in some way.


Comments

Popular posts from this blog

Eclipse CDT variable colors in editor -

AJAX doesn't send POST query -

wpf - Custom Message Box Advice -