Socket programming....

Please support our VB.NET advertiser: Intel Parallel Studio Home
Thread Solved

Join Date: Jun 2009
Posts: 8
Reputation: scsachira is an unknown quantity at this point 
Solved Threads: 0
scsachira scsachira is offline Offline
Newbie Poster

Socket programming....

 
0
  #1
Jul 2nd, 2009
I'm designing chat application these days.. I tried several samples which i found from the web..
I designed Server and Client..
When i run client in my machine, server get it nicely..
but when server in my machine and client in other machine, server doesn't detect client..
I tried 5+ samples from the web.. every sample work like that.

In here we have dynamic IP address. is that the reason for my problem?
Is server need static IP address?

Give me help please... I'm totally stuck in here...
Reply With Quote Quick reply to this message  
Join Date: Jun 2009
Posts: 228
Reputation: GeekByChoiCe is on a distinguished road 
Solved Threads: 40
GeekByChoiCe GeekByChoiCe is offline Offline
Posting Whiz in Training

Re: Socket programming....

 
0
  #2
Jul 2nd, 2009
Is your server behind a router? if so just set the portforwarding to the port the server is using and forward it to the machine on what the server is running.
And also make sure the Client is connecting to the right IP and port
Reply With Quote Quick reply to this message  
Join Date: Jun 2009
Posts: 8
Reputation: scsachira is an unknown quantity at this point 
Solved Threads: 0
scsachira scsachira is offline Offline
Newbie Poster

Re: Socket programming....

 
0
  #3
Jul 2nd, 2009
Originally Posted by GeekByChoiCe View Post
Is your server behind a router? if so just set the portforwarding to the port the server is using and forward it to the machine on what the server is running.
And also make sure the Client is connecting to the right IP and port
I'm using ADSL modem to connect to Net..
I checked IP and port.. Both are same in the server and client.

Actually I'm selfstuding VB.net. Therefore, if u can give me code sample for it, it's vary valuble for me.

However thanks for Reply....
Reply With Quote Quick reply to this message  
Join Date: Jun 2009
Posts: 228
Reputation: GeekByChoiCe is on a distinguished road 
Solved Threads: 40
GeekByChoiCe GeekByChoiCe is offline Offline
Posting Whiz in Training

Re: Socket programming....

 
0
  #4
Jul 3rd, 2009
source code is attached. this is a VERY basic server/client application

for adjusting:
in the client application just change it to your needs ...
  1. Private Sub BGW1_DoWork(ByVal sender As Object, ByVal e As System.ComponentModel.DoWorkEventArgs) Handles BGW1.DoWork
  2. Try
  3. myClient = New TcpClient("localhost", 5000)
  4. BGW1.ReportProgress(100)
  5. Catch ex As SocketException
  6. e.Result = "offline"
  7. End Try
  8. End Sub

in the server App:

  1. Private Sub DoListen()
  2. Try
  3. Listener = New TcpListener(Dns.GetHostEntry("localhost").AddressList(0), 5000)
  4. Listener.Start()
  5.  
  6. Do
  7. Dim connectedClients As New clientClass(Listener.AcceptTcpClient)
  8. AddHandler connectedClients.Disconnected, AddressOf connectedClients_Disconnected
  9. AddHandler connectedClients.LineReceived, AddressOf connectedClients_LineReceived
  10. Clients.Add(connectedClients.ID, connectedClients)
  11. Loop Until False
  12.  
  13. Catch
  14. End Try
  15. End Sub

hope it helps
Attached Files
File Type: zip Chat Application.zip (110.7 KB, 15 views)
Reply With Quote Quick reply to this message  
Join Date: Jun 2009
Posts: 8
Reputation: scsachira is an unknown quantity at this point 
Solved Threads: 0
scsachira scsachira is offline Offline
Newbie Poster

Re: Socket programming....

 
0
  #5
Jul 4th, 2009
Hey... GeekByChoiCe..
Problem was solved..
Thanks for help me..
Thank u very much..
U r great..
Reply With Quote Quick reply to this message  
Reply

This thread has been marked solved.
Perhaps start a new thread instead?
Message:


Thread Tools Search this Thread



About Us | Contact Us | Advertise | DaniWeb | Acceptable Use Policy | RSS Feed

©2003 - 2009 DaniWeb® LLC