TECHNOLOGIES
FORUMS
JOBS
BOOKS
EVENTS
INTERVIEWS
Live
MORE
LEARN
Training
CAREER
MEMBERS
VIDEOS
NEWS
BLOGS
Sign Up
Login
No unread comment.
View All Comments
No unread message.
View All Messages
No unread notification.
View All Notifications
Answers
Post
An Article
A Blog
A News
A Video
An EBook
An Interview Question
Ask Question
Forums
Monthly Leaders
Forum guidelines
Ahmad
NA
48
0
Client Server
Oct 31 2008 8:45 AM
Hi everybode iam making a client server program when i request a connect to the server the client give me an Exception that the computer refuse it here is the code of the client program : ************************************************************* Socket scc; private void Connection_btn_Click(object sender, EventArgs e) { String tip = Ip_txt.Text; String tport = Port_txt.Text; scc = new Socket(AddressFamily.InterNetwork, SocketType.Stream, ProtocolType.Tcp); IPAddress ip = IPAddress.Parse(tip); int port = Int32.Parse(tport); IPEndPoint endpoint = new IPEndPoint(ip, port); scc.Connect(endpoint); if (scc.Connected) { statusStrip1.Text = "Connected"; } } in the server code i put a thread in the form load to start when the form is loaded here is the thread code (a thread job is to listen on the port) : public void listen() { //MessageBox.Show("inside listen"); sc = new Socket(AddressFamily.InterNetwork, SocketType.Stream, ProtocolType.Tcp); //Check why it is true********************* sc.Blocking = false; IPAddress ip = IPAddress.Parse(ipText.Text); int port = Int32.Parse(portText.Text); IPEndPoint endpoint = new IPEndPoint(ip, port); sc.Bind(endpoint); while (true) { //MessageBox.Show("before listen"); // MessageBox.Show("After listen"); if (sc.Connected) { sc.Listen(10); client = sc.Accept(); //clientsock = serversocket.Accept(); MessageBox.Show("Accepted"); client = sc.Accept(); if (client == null) { MessageBox.Show("Winsock error: " + Convert.ToString(System.Runtime.InteropServices.Marshal.GetLastWin32Error())); this.Close(); } if (client.Connected) { host = (IPEndPoint)client.LocalEndPoint; comboBox1.Items[counter] = host.Address.ToString(); counter++; tc = new Thread(new ThreadStart(makethread)); tc.Start(); } } } } Note: the ip that i put it in the textbox is 127.0.0.1 and the port 5555 in both the server and client.
Reply
Answers (
3
)
Dictionary size issue
reading a text file, line by line and put it in 3D array in C#