kāpēc Bind () funkcija atgriež -1

S

scorrpeio

Guest
Es šobrīd dara ligzda plānošanu UDP ar VC , izmantojot Visual Studio 2005, ja es izmanto Bind () funkciju, lai tas kļūtu saistošs kontaktligzdu.Bet es everytime izpaužas rezultāts .......... Bind neizdevās.
Kad es paņemts, funkcija Bind () atgriež -1.
I dont get kāpēc tas notiek?Lūdzu, let me know./ / Izveidot Socket

int ServerSocket;
ServerSocket = ligzda (PF_INET, SOCK_DGRAM, 0);

/ / Pārbaudiet esamību

ja (ServerSocket <0)
(
MessageBox ("Socket nav izveidots!");
)

/ / Bind Socket

int MySock;
struktūrai sockaddr_in MyAddr;

MySock = ligzda (PF_INET, SOCK_DGRAM, 0);
MyAddr.sin_family = AF_INET;
MyAddr.sin_addr.s_addr = inet_addr (m_IPAdd);
MyAddr.sin_port = htonl (m_iPortNo);

saistošs (ServerSocket, (SOCKADDR *) un MyAddr, sizeof (MyAddr));

ja (sasaistīt (ServerSocket, (SOCKADDR *) un MyAddr, sizeof (MyAddr)) == SOCKET_ERROR)
(
MessageBox ("saistošs () neizdevās)."
closesocket (ServerSocket);
atgriezties;
)

 

Welcome to EDABoard.com

Sponsor

Back
Top