c# - WIFI Direct IP Address issue -


i have checked , found problem ip address being assigned connectionendpointpair carrying ip of wi-fi direct network adapter , don't know how open port on specific ip, ip different when ping pc windows listening on port 5009 , connection established when use wi-fi ip when use wi-fi direct ip addresses i'm having issue

the wi-fi direct connection between device , windows 8.1 application ok, awaiting sockets connect not happen issue ?

i error on visual studio:

no connection made because target machine actively refused it. (exception hresult: 0x8007274d)

on windows side using code:

string deviceselector = wifidirectdevice.getdeviceselector();          deviceinformationcollection devicecollection = await deviceinformation.findallasync(deviceselector);          if(devicecollection.count > 0)         {             try             {                 wfddevice = await wifidirectdevice.fromidasync(devicecollection[0].id);                  wfddevice.connectionstatuschanged +=connectionstatuschangednotficationhandler;                    var endpointpairs = wfddevice.getconnectionendpointpairs();                 endpointpair connectionendpointpair = endpointpairs[0];                  try                 {                     connectionendpointpair.remoteservicename = "5009";                       streamsocket socket = new streamsocket();                     await socket.connectasync(connectionendpointpair);                      string s = "hello";                 }catch (exception err)                 {                     string s = err.message;                     s = err.stacktrace;                 }             }             catch (exception err)             {                 string error = err.message;              } 

on android side using code:

               private void initiateclientsocket(string hostaddress) {           int timeout = 10000;         int port = 5009;          inetsocketaddress socketaddress            = new inetsocketaddress(hostaddress, port);          try {           socket socket = new socket();           socket.bind(null);           socket.connect(socketaddress, timeout);         } catch (ioexception e) {           log.e(tag, "io exception.", e);         }          // todo start receiving messages       } 

from android side getting:

java.net.unknownhostexception: host unresolved: ip

can please

thanks :)

even if have direct wifi connection between android phone , windows computer, need server , client tcp connection.

i don't know purpose of application assume windows computer better choice server. instead connecting socket, on computer should open listener port.

the server class related chosen streamsocket class streamsocketlistener. can find documentation here: http://msdn.microsoft.com/en-us/library/windows/apps/windows.networking.sockets.streamsocketlistener.aspx

there paragraph in documentation typical order of operations:

  • create streamsocketlistener.
  • use control property retrieve streamsocketlistenercontrol object , set socket quality of service required.
  • assign connectionreceived event event handler.
  • call bindservicenameasync or bindendpointasync method bind local tcp port or service name.
  • when connection received, use streamsocketlistenerconnectionreceivedeventargs object retrieve socket property streamsocket object created.
  • use streamsocket object send , receive data.
  • call close method stop listening , accepting incoming network connections , release unmanaged resources associated streamsocketlistener object. streamsocket objects created when connection received unaffected , can continue used needed.

i haven't worked special class, basics of tcp same...


Comments

Popular posts from this blog

java - Run a .jar on Heroku -

java - Jtable duplicate Rows -

validation - How to pass paramaters like unix into windows batch file -