943,521 Members | Top Members by Rank

Ad:
  • VB.NET Discussion Thread
  • Marked Solved
  • Views: 877
  • VB.NET RSS
Jul 2nd, 2009
0

Socket programming....

Expand Post »
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...
Similar Threads
Reputation Points: 10
Solved Threads: 0
Newbie Poster
scsachira is offline Offline
8 posts
since Jun 2009
Jul 2nd, 2009
0

Re: Socket programming....

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
Featured Poster
Reputation Points: 208
Solved Threads: 168
Practically a Master Poster
GeekByChoiCe is offline Offline
692 posts
since Jun 2009
Jul 2nd, 2009
0

Re: Socket programming....

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....
Reputation Points: 10
Solved Threads: 0
Newbie Poster
scsachira is offline Offline
8 posts
since Jun 2009
Jul 3rd, 2009
0

Re: Socket programming....

source code is attached. this is a VERY basic server/client application

for adjusting:
in the client application just change it to your needs ...
vb Syntax (Toggle Plain Text)
  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:

vb Syntax (Toggle Plain Text)
  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, 27 views)
Featured Poster
Reputation Points: 208
Solved Threads: 168
Practically a Master Poster
GeekByChoiCe is offline Offline
692 posts
since Jun 2009
Jul 4th, 2009
0

Re: Socket programming....

Hey... GeekByChoiCe..
Problem was solved..
Thanks for help me..
Thank u very much..
U r great..
Reputation Points: 10
Solved Threads: 0
Newbie Poster
scsachira is offline Offline
8 posts
since Jun 2009

This thread is solved

Either the thread starter or a moderator has marked this thread as solved. You can most likely trust the responses and answers given. There is most likely no reason for any further responses to be posted here. If you have a related question, please start a new thread in this forum instead.

This thread is more than three months old

No one has posted to this discussion for at least three months. Please let old threads die and do not reply to them unless you feel you have something new and valuable to contribute that absolutely must be added to make the discussion complete. Otherwise, please start a new thread in this forum instead.
Message:
Previous Thread in VB.NET Forum Timeline: SQL
Next Thread in VB.NET Forum Timeline: How to build the correct way of n-tier apps without service and remoting?





About Us | Contact Us | Advertise | Acceptable Use Policy
Forum Index | Build Custom RSS Feed


Follow us on Twitter


© 2011 DaniWeb® LLC