Hello, currently I am trying to send a byte array to a wireless device I have setup on my network. I'm having issues however and it's not working properly. I can send data to it while I have it interfaced usb, but over the network has been unsuccesful.
This is what I have so far for my code and it's giving me an error SocketException "The requested address is not valid in its context" Here is the code I am trying to use currently.
static void Main(string[] args)
{
IPEndPoint ip = new IPEndPoint((IPAddress.Parse("192.168.2.28")), 2101);
Socket socket = new Socket(AddressFamily.InterNetwork, SocketType.Stream, ProtocolType.Tcp);
socket.Bind(ip);
socket.Listen(7); //i'm not exactly sure how I should know which I should Listen to. This is a wireless device. It was set at 10, so I moved it to 7.
Console.WriteLine("Waiting for a client...");
Socket client = socket.Accept();
IPEndPoint clientep = (IPEndPoint)client.RemoteEndPoint;
Console.WriteLine("Connected with {0} at port {1}", clientep.Address, clientep.Port);
byte[] data = new byte[]{254, 0, 7};
client.Send(data, data.Length, SocketFlags.None);
Console.WriteLine("Disconnected from {0}", clientep.Address);
client.Close();
socket.Close();
}