I have 2 windows PC's connected over an ad-hoc wlan network.
Using this existing connection can I communicate between these pc's via sockets?
Can I open a server socket on one pc and make the other pc a client and connect to the other pc and then send and receive data over this connection?
Do I need a specific api for this or can I just use java.net.Socket
and java.net.ServerSocket
?
views:
330answers:
2Of course you can. There is an IP network over the WLAN connection, and nothing stops you from establinshing TCP connection.
As far as sockets are concerned this is no different to a wired (Ethernet) connection, the difference ends at Data-Link layer
Of course you can use (Server)Sockets. Sockets are a concept of the TCP-protocol (OSI-layer 4), which operates on top of the IP-protocol (OSI-layer 3), which itself operates on top of WLAN or Ethernet (OSI-layer 2), which operates on a physical link (radio waves for WLAN, ethernet cables for ethernet).
The Implementations of the OSI-layers are replaceable (or better: should be replaceable). So it doesn't matter if you are using WLAN, ethernet or something else, as long as you don't go below layer 3 (which isn't possible with Java anyway).
Have a look at the Wikipedia article for more information