Visual Basic .NET Forums  
Click here to advertise with us

Go Back   Visual Basic .NET Forums > Components & Controls > Net / Sockets

Net / Sockets Components for network and related use

VB.NET Forums Newsletter Signup:
Email address:


Reply
 
LinkBack Thread Tools Display Modes
  #1 (permalink)  
Old 06-29-2009, 9:15 AM
VB.NET Forum Newbie
.NET Framework: .NET 3.5 (VS 2008)
 
Join Date: Jun 2009
Posts: 3
Reputation: 0
gadile2 is on a distinguished programming path ahead
Default client server application

Hey,
I am looking for help in solving a problem I have.

I have a code for client server application taken from the visual studio 2008 help. The thing is it is written in VB6 and I have been working for hours now trying to make the adjustments so it would work but still havn't been successful. I started thinking about leaving VB and just write everything in python.

Before giving up, I decided to try and get help in here.

The specific problem is that pressing the connect button in the client's form doesn't seem to have any result.
---------------------------------------
server 's code:

Public Class frmServer
Private Sub frmServer_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
' Set the LocalPort property to an integer.
' Then invoke the Listen method.
tcpServer.LocalPort = 8000
tcpServer.Listen()
frmClient.Show() ' Show the client form.
End Sub
Private Sub tcpServer_ConnectionRequest _
(ByVal requestID As Long)
MsgBox("333")
' Check if the control's State is closed. If not,
' close the connection before accepting the new
' connection.
If tcpServer.CtlState <> "8" Then _
tcpServer.Close()
' Accept the request with the requestID
' parameter.
tcpServer.Accept(requestID)
End Sub

Private Sub txtSendData_Change()
MsgBox("444")
' The TextBox control named txtSendData
' contains the data to be sent. Whenever the user
' types into the textbox, the string is sent
' using the SendData method.
tcpServer.SendData(txtSendData.Text)
End Sub

Private Sub tcpServer_DataArrival _
(ByVal bytesTotal As Long)
MsgBox("555")
' Declare a variable for the incoming data.
' Invoke the GetData method and set the Text
' property of a TextBox named txtOutput to
' the data.
Dim strData As String
strData = String.Empty
tcpServer.GetData(strData)
txtOutput.Text = strData
End Sub
End Class
---------------------------------------------------
client's code:

Public Class frmClient
Private Sub frmClient_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
' The name of the Winsock control is tcpClient.
' Note: to specify a remote host, you can use
' either the IP address (ex: "121.111.1.1") or
' the computer's "friendly" name, as shown here. f45d87107
' tcpClient.RemoteHost = "192.168.2.201"
tcpClient.RemoteHost = "127.0.0.1"
tcpClient.RemotePort = 8000
End Sub

Private Sub cmdConnect_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles cmdConnect.Click
' Invoke the Connect method to initiate a connection.
'tcpClient.Connect("127.0.0.1", 1001)
tcpClient.Connect("127.0.0.1", 8000)
MsgBox("000")
End Sub

Private Sub txtSend_Change()
MsgBox("111")
tcpClient.SendData(txtSend.Text)
End Sub

Private Sub tcpClient_DataArrival _
(ByVal bytesTotal As Long)
MsgBox("222")
Dim strData As String
strData = String.Empty
tcpClient.GetData(strData)
txtOutput.Text = strData
End Sub

End Class
-----------------------------------

I would highly appreciate any help,
rgds,
Gadi
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #2 (permalink)  
Old 06-29-2009, 5:50 PM
VB.NET Forum Newbie
.NET Framework: .NET 3.5 (VS 2008)
 
Join Date: Jun 2009
Age: 20
Posts: 4
Reputation: 0
twittumz is on a distinguished programming path ahead
Default

Code:
imports system.net.sockets
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #3 (permalink)  
Old 06-30-2009, 8:41 AM
VB.NET Forum Newbie
.NET Framework: .NET 3.5 (VS 2008)
 
Join Date: Jun 2009
Posts: 3
Reputation: 0
gadile2 is on a distinguished programming path ahead
Default

Hey,

many thanks for the quick reply but it still doesn't work.

Any ideas?
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #4 (permalink)  
Old 06-30-2009, 8:50 AM
JohnH's Avatar
VB.NET Forum Moderator
.NET Framework: .NET 3.5 (VS 2008)
 
Join Date: Dec 2005
Location: Norway
Age: 37
Posts: 10,173
Reputation: 1273
JohnH has a reputation beyond reputeJohnH has a reputation beyond reputeJohnH has a reputation beyond reputeJohnH has a reputation beyond reputeJohnH has a reputation beyond reputeJohnH has a reputation beyond reputeJohnH has a reputation beyond reputeJohnH has a reputation beyond reputeJohnH has a reputation beyond reputeJohnH has a reputation beyond reputeJohnH has a reputation beyond repute
Default

For socket application in .Net I suggest you use the TcpClient and TcpListener classes found in System.Net.Sockets namespace.
__________________
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #5 (permalink)  
Old 06-30-2009, 12:01 PM
VB.NET Forum Newbie
.NET Framework: .NET 3.5 (VS 2008)
 
Join Date: Jun 2009
Age: 20
Posts: 4
Reputation: 0
twittumz is on a distinguished programming path ahead
Default

Uhh check out
System.Net Namespace ()

TcpListener Class
TcpListener Class (System.Net.Sockets)

TcpClient Class
TcpClient Class (System.Net.Sockets)

those should help you..
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #6 (permalink)  
Old 06-30-2009, 3:58 PM
VB.NET Forum Newbie
.NET Framework: .NET 3.5 (VS 2008)
 
Join Date: Jun 2009
Posts: 3
Reputation: 0
gadile2 is on a distinguished programming path ahead
Default

a thusands thanks for the replyers.

But, it seems that the source of my problem is trying to use vb6 code in .vb application (visual studio 2008).

So I downloaded a code written in .VB and I'll see if I can get it work.

rgds,
Gadi
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Reply

Bookmarks


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On





All times are GMT -4. The time now is 10:32 AM.

Powered by vBulletin® Version 3.8.4
Copyright ©2000 - 2010, Jelsoft Enterprises Ltd.
Search Engine Optimization by vBSEO 3.3.2


For advertising opportunities click here.