Quantcast
Channel: Silverlight 5 forum
Viewing all articles
Browse latest Browse all 1083

Silverlight 5 Socket class help

$
0
0

i am using the code below to connect to my other computer that is running a c# server. But its not connecting. 

 private Socket socket;
        private byte[] transferBuffer;
        private SocketAsyncEventArgs sendEventArgs;

        // contants
        private static int BUFFER_SIZE = 700;
        private static int PORT = 5333;
        private static DnsEndPoint IP_END_POINT = new DnsEndPoint("192.168.0.11", PORT);
        public delegate void SetTextCallback(String _text);


        public MainPage()
        {
            InitializeComponent();
            App.Current.Host.Content.Resized += new EventHandler(Content_Resized);

            socket = new Socket(AddressFamily.InterNetwork, SocketType.Stream, ProtocolType.Tcp);
            SocketAsyncEventArgs connectEventArgs = new SocketAsyncEventArgs();
            connectEventArgs.RemoteEndPoint = IP_END_POINT;
          
            connectEventArgs.Completed += new EventHandler<SocketAsyncEventArgs>(connectEventArgs_Completed);
            socket.ConnectAsync(connectEventArgs);
            messageBox.Text += "Trying to connect";


        }

       

        void connectEventArgs_Completed(object sender, SocketAsyncEventArgs e)
        {
            messageBox.Text += "Connections complete";
            sendEventArgs = new SocketAsyncEventArgs();
            sendEventArgs.RemoteEndPoint = IP_END_POINT;

            e.Completed -= new EventHandler<SocketAsyncEventArgs>(connectEventArgs_Completed);
            e.Completed += new EventHandler<SocketAsyncEventArgs>(receiveEventArgs_Completed);
            transferBuffer = new byte[BUFFER_SIZE];
            e.SetBuffer(transferBuffer, 0, transferBuffer.Length);
            socket.ReceiveAsync(e);

          
        }

I read some stuff online about silverlight beta 2 being limited to certain port ranges. I am not sure if that the case for Silverlight 5.  I think the problem might be that , the server is in my local network. So it cannot connect to it. What do you guys think?


Viewing all articles
Browse latest Browse all 1083

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>