Click here to Skip to main content
15,885,366 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
i have done a server using this example How To Use the SocketAsyncEventArgs Class[^]

in visual studio 2010 and .net 4.0.

Now i'm trying to connect to it from a windows 8 app using StreamSocket but i'm getting a "Acces denied" message.
here is the Client code:

C#
private StreamSocket streamSocket;
        public string Server = "192.168.0.101";
        public int Port = 9900;

        public async void Connect()
        {
            streamSocket = new StreamSocket();
            Connect();
            try
            {
                await streamSocket.ConnectAsync(
                    new Windows.Networking.HostName(Server),
                    Port.ToString()); // getting Acces Denied here

                DataReader reader = new DataReader(streamSocket.InputStream);
                reader.InputStreamOptions = InputStreamOptions.Partial;
                while (true)
                {
                    var bytesAvailable = await reader.LoadAsync(1000);
                    var byteArray = new byte[bytesAvailable];
                    reader.ReadBytes(byteArray);

                }
            }
            catch (Exception e)
            {
                MessageBox(e.StackTrace);
            }
        }


How to fix the problem? Is there another way to send and receive messages?

Thanks,
Posted

1 solution

Please add Private Networks (Client & Server) capability in Manifest


Thanks,
Bilaal
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900