socket connection problem

G

Guest

HElp! Im new heres my code:

public class SocketExcept
{
public static void Main()
{
IPAddress host = IPAddress.Parse("192.168.1.1");
IPEndPoint hostep = new IPEndPoint(host, 8000);
Socket sock = new Socket(AddressFamily.InterNetwork,
SocketType.Stream, ProtocolType.Tcp);

try
{
sock.Connect(hostep);
} catch (SocketException e) {
Console.WriteLine("Problem connecting to host");
Console.WriteLine(e.ToString());
sock.Close();
return;
}

try {
sock.Send(Encoding.ASCII.GetBytes("testing"));
} catch (SocketException e) {
Console.WriteLine("Problem sending data");
Console.WriteLine( e.ToString());
sock.Close();
return;
}
sock.Close();
}
}

My server ip is 192.168.1.1 and port 800. I have 3 IP addresses here in my
pc 192.168.30.1, 192.168.30.2 and 192.168.30.3. My problem is that i want my
socket to use my ip 192.168.60.30.1 to connect to the server 192.168.60.1.1..
how do i do this? please i really need this.. help! Thank you so much in
advance and help would do.. thank you again! BTW, I must use Socket and not
TCP.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top