Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

有關IP連線設定

4 views
Skip to first unread message

vinanne68

unread,
Apr 13, 2007, 4:52:01 AM4/13/07
to
最近用vb.net寫一個透過IP連線來控制設備的程式
看了好多的討論及MSDN說明,可是還是連 不上
我已知道設備的IP address, 不知那位好心人可幫忙一下
要透過IP連線,應該如何下指令.

璉璉

unread,
Apr 13, 2007, 8:56:45 AM4/13/07
to
請配合你的設備所載白皮書,使用 TcpClient 類別。

==> 本文由 "vinanne68 <vina...@discussions.microsoft.com>"
> 於 news:9D467AAC-F595-430E-BADC-9B7D77A323F1%40microsoft.com 發表

--
風禹科技驗證有限公司 ASP.NET Web News Reader 0.2.6 UTF-8 Beta
網站地圖 http://tlcheng.twbbs.org/wwwmap.htm
流域防洪/區域水資源/徐昇網/玫瑰圖/語音通訊 文章與程式
Basic/Fortran/Windows API/.Net/輔助說明檔 原始碼、文章與討論
微軟程式設計、系統管理使用新技術論壇討論區,網友回覆後即時簡訊、電子郵件通知:
MSDN: http://forums.microsoft.com/msdn-cht/default.aspx?siteid=14
TechNet: http://forums.microsoft.com/technet-cht/default.aspx?siteid=23
--
ASPNET News Reader http://tlcheng.twbbs.org/News/Reader.aspx
RSS 2.0 http://tlcheng.twbbs.org/News/rss2.aspx?Action=List&Newsgroup=microsoft.public.tw.dotnet.languages.vb

vinanne68

unread,
Apr 14, 2007, 1:50:02 AM4/14/07
to
使用璉璉建議的 TcpClient 類別
已經可以使用了。
謝謝啦

"璉璉" 來函:

vinanne68

unread,
Apr 18, 2007, 11:30:35 PM4/18/07
to
請問一下璉璉:

我使用TcpClient(server, port)來連線
是可以用了
可是有一個問題不知你可幫忙解決
我是按一個按鈕後就送一個詢問出去,後會自動回應。
可是點一點後程式就會當掉,或是傳回來的訊息只接收一半。
程式如 下:
Dim server As String = "192.168.1.50"
Dim port As Int32 = 20000
Dim client As New TcpClient(server, port)
Dim message as string = "TX"

' Translate the passed message into ASCII and store it as a Byte
array.
Dim Message As String = "TX" & Chr(13) & Chr(10)
Dim data As [Byte]() = System.Text.Encoding.ASCII.GetBytes(Message)

' Get a client stream for reading and writing.
' Stream stream = client.GetStream();
Dim stream As NetworkStream = client.GetStream()

' Send the message to the connected TcpServer.
stream.Write(data, 0, data.Length)

Console.WriteLine("Sent: {0}", Message)

' Receive the TcpServer.response.
' Buffer to store the response bytes.
data = New [Byte](256) {}

' String to store the response ASCII representation.
Dim responseData As [String] = [String].Empty

' Read the first batch of the TcpServer response bytes.
Dim bytes As Int32 = stream.Read(data, 0, data.Length)
responseData = System.Text.Encoding.ASCII.GetString(data, 0, bytes)
Console.WriteLine("Received: {0}", responseData)

TextBox1.Text = responseData

' Close everything.
stream.Close()
client.Close()

"璉璉" 來函:

璉璉

unread,
Apr 19, 2007, 8:21:46 AM4/19/07
to
你可以先參考新站這邊的既有討論:
http://forums.microsoft.com/MSDN-CHT/Search/Search.aspx?words=TcpClient+MemoryStream&localechoice=31748&SiteID=14&searchscope=allforums

==> 本文由 "vinanne68 <vina...@discussions.microsoft.com>"
> 於 news:ACB6AD33-B170-4F02-8771-D6718D6A56CD%40microsoft.com 發表

0 new messages