0
我試圖使用WiFi直連,所以我必須在服務器上的代碼從客戶端連接到插座的服務器連接與Android插座:如何使用WiFi直接
ServerSocket serverSocket = new ServerSocket(2009);
Socket client = serverSocket.accept();
,我有這個客戶端上的代碼
final WifiP2pDevice peer = wifiP2pDeviceList.get("aMacAddress");
WifiP2pConfig config = new WifiP2pConfig();
config.deviceAddress=peer.deviceAddress;
mManager.connect(mChannel,config,new WifiP2pManager.ActionListener() {
@Override
public void onSuccess() {
mManager.requestGroupInfo(mChannel,new WifiP2pManager.GroupInfoListener() {
@Override
public void onGroupInfoAvailable(WifiP2pGroup group) {
try {
Socket socket = new Socket();
int port = 2009;
int timeout = 5000;
socket.bind(null);
socket.connect((new InetSocketAddress(peer.deviceAddress, port)), SOCKET_TIMEOUT); // Error here
}
catch (IOException e){
e.printStackTrace();
}
我可以直接使用MAC地址或我的其他解決方案嗎?
哪個設備的MAC地址? – greenapps 2014-12-02 22:55:08