Click here to Skip to main content
15,888,351 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Dear
I would like to ask about the ability to use the winsock in wireless network?
i.e. Can i use the winsock to send and receive frame between two computer connecting in ad hoc network?

With my great thanks.

MSC. Student suad alasasi, babylon university, iraq
Posted
Updated 29-May-11 1:02am
v2

1 solution

Yes you can. Winsocket API is not restricted to any transport media. Wireless, wired etc. it will work if every thing is setup correct.

To initialize Winsocket (disregard of transport media) you then
C++
WSADATA wsaData;

// Initialize Winsock
int iResult = WSAStartup(MAKEWORD(2,2), &wsaData);

if (iResult != 0)
{
    printf("WSAStartup failed: %d\n", iResult);
}
else
{
    printf("WSAStartup OK\n");
}


After this you can call connect method etc.

There is a good Getting Started with Winsock[^].
Do not confuse your self that it is wireless via Wi-Fi.

This link a good example of server and client, both on TCP or UDP connection.
http://www.tenouk.com/Winsock/Winsock2example9.html[^]
 
Share this answer
 
v3
Comments
suad2010 29-May-11 5:49am    
thank you very much for replying my question , i have another question please i wounder if i must initialize the wireless in winsock library?if the answer is yes how can i do it? with`my great thanks
Kim Togo 29-May-11 6:55am    
See updated answer.
thatraja 29-May-11 11:15am    
Hi, I suggest you to vote Kim's answer & you can accept this as an answer.
suad2010 29-May-11 11:20am    
yes, thank you,but i have another request please
i want a good project in c++ for (UDP winsock client-server code )?
with my great thanks
Kim Togo 30-May-11 2:30am    
See this exmaple: http://www.tenouk.com/Winsock/Winsock2example9.html
It can handle TCP or UDP datagrams. There is both a server and client code examples.
If this solved your question, then please "Accept Answer"

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900