in c#.net how to send message to remote computer throught internet? -


c#.net framework 4.0 client profile,windows application.. developing game needs send current movements of game through internet remote computer same application(game) installed.in same way current movements of game of remote computer should send back... how possible ?

to need implement client-server behavior through tcp/ip
there different ways this code i've written give start (it's option, not one, leave off choose method suits best)

using system.runtime.remoting; using system.runtime.remoting.channels; using system.runtime.remoting.channels.tcp;  static class serverprogram {             [stathread]     static void main()     {              atsserver();          }          static void atsserver()     {                 tcpchannel tcpchannel = new tcpchannel(7000);         channelservices.registerchannel(tcpchannel);          type commoninterfacetype = type.gettype("atsremotecontrol");         remotingconfiguration.registerwellknownservicetype(commoninterfacetype,         "remoteatsserver", wellknownobjectmode.singlecall);     } }  public interface atsremotecontrolinterface {     string yourremotemethod(string parameter); }        public class atsremotecontrol : marshalbyrefobject, atsremotecontrolinterface {     public string yourremotemethod(string gamermovementparameter)         {             string returnstatus = "game movement launched";             console.writeline("enquiry {0}", gamermovementparameter);             console.writeline("sending status: {0}", returnstatus);             return returnstatus;         } }  class atslauncherclient {     static atsremotecontrolinterface remoteobject;      public static void registerserverconnection()     {         tcpchannel tcpchannel = new tcpchannel();         channelservices.registerchannel(tcpchannel);          type requiredtype = typeof(atsremotecontrolinterface);          //here adjust remote tcp/ip address          //implement retrieval programatically rather hardcoding         remoteobject = (atsremotecontrolinterface)activator.getobject(requiredtype,         "tcp://localhost:7000/remoteatsserver");          string s = "";         s = remoteobject.yourremotemethod("gamermovement");       }      public static void launch(string gamermovementparameter)     {         remoteobject.yourremotemethod(gamermovementparameter);     } } 

hope helps.


Comments

Popular posts from this blog

asp.net - repeatedly call AddImageUrl(url) to assemble pdf document -

java - Android recognize cell phone with keyboard or not? -

iphone - How would you achieve a LED Scrolling effect? -