warlordluke 0 Report post Posted November 28, 2005 Hi allThis is how you make a basic Client/Server Chat(Server Side)For this code you require- 2 Textboxes (You can call them anything you want but i'm going to call them txthst (Chat history) txtmsg (Chat Message))- 1 Command Button (You can call it what ever you want but i'm going call it cmdsnd (To Send Messages))- 1 Winsock Control (You can call it what ever you want but i'm going to call it ws (To listen))MainFrm.frmMenu- Exit Private Sub Form_Load() ws.LocalPort = 12345 ws.ListenEnd SubPrivate Sub Winsock_ConnectionRequest(ByVal RequestID As Long) ws.Close ws.Accept RequestIDEnd SubPrivate Sub Winsock_DataArrival(ByVal bytesTotal As Long)Dim strData As String ws.GetData strData txthst.Text = txthst.Text & vbCrLf & strData txthst.SelStart = Len(txthst.Text)End SubPrivate Sub cmdsnd_Click() Winsock.SendData txtChat.Text DoEvents txthst.Text = txthst.Text & vbCrLf & txtmsg.Text txtmsg.Text = ""End Sub (Client Side)For this code you require- 2 Textboxes (You can call them anything you want but i'm going to call them txthst (Chat history) txtmsg (Chat Message))- 1 Command Button (You can call it what ever you want but i'm going call it cmdsnd (To Send Messages))- 1 Winsock Control (You can call it what ever you want but i'm going to call it ws (To Connect to the server))Private Sub Form_Load() ws.RemoteHost = "127.0.0.1" ws.RemotePort = 12345 ws.ConnectEnd SubPrivate Sub cmdSend_Click() ws.SendData txtmsg.Text DoEvents txthst.Text = txthst.Text & vbCrLf & txtmsg.Text txtmsg.Text = ""End SubPrivate Sub Winsock_Connect() MsgBox "Connected"End SubPrivate Sub Winsock_DataArrival(ByVal bytesTotal As Long)Dim strData As String ws.GetData strData txthst.Text = txtmsg.Text & vbCrLf & strData txthst.SelStart = Len(txthst.Text)End SubPrivate Sub Winsock_Error(ByVal Number As Integer, Description As String, _ ByVal Scode As Long, ByVal Source As String, ByVal HelpFile As String, _ ByVal HelpContext As Long, CancelDisplay As Boolean) MsgBox "Error: " & DescriptionEnd Sub There you go people and entier tutorial on a basic person to person chat system using winsock and you can expand on this in many different ways. Example adding images to show the different states of the winsock control. (I may show this later) Share this post Link to post Share on other sites
wow 0 Report post Posted November 29, 2005 You wouldnt have the server side code for the old vp chat client would you?....lolAlso would this code you posted could it be applyed to my Xisto account? Share this post Link to post Share on other sites
JpOlDeRmAn 0 Report post Posted July 29, 2006 Nice i tried here right now and it's working but i have a router so nobody can chat with me on my server Share this post Link to post Share on other sites
Galahad 0 Report post Posted August 1, 2006 Nice i tried here right now and it's working but i have a router so nobody can chat with me on my server You need to configure your router, to forward all incoming data on certain port, to port that your chat server is using for incoming connectios... I think that should do the trick... All have your router forward all the ports to your computer, so all requests would be processed on your computer... Share this post Link to post Share on other sites