当前位置:首页 > 网络编程 > 软件语言 > .NET > asp.net的vb7中如何使用socket作一个传送时间的server

asp.net的vb7中如何使用socket作一个传送时间的server

点击次数:81 次 发布日期:2008-11-06 07:51:12 作者:源代码网
源代码网推荐
广告载入中

源代码网整理以下利用Socket 可以编写一个 向 客户端传送 时间的 一个程序,现在他还只能向
固定的客户端 传送时间,我打算过几天 写一个 可以向 浏览器传送 时间的一个程序
请大家随时注意我的站点的更新情况。。。
Imports System
Imports System.Net
Imports System.Net.Sockets
Imports System.Text

源代码网整理以下Public Class DateTimeServer
Public Shared Sub temp()
System.Console.WriteLine("hello")
Console.Writeline("Hello ")
End Sub

软件开发网 www.mscto.com

源代码网整理以下Public Shared Sub Main()
Dim now As Date
Dim strDateLine As String
Dim ASCII As Encoding = Encoding.ASCII 软件开发网 www.mscto.com

源代码网整理以下Dim tcpl As New TCPListener(13) "listen on port 13

源代码网整理以下tcpl.Start()

源代码网整理以下Console.WriteLine("Waiting for clients to connect")
Console.WriteLine("Press Ctrl c to Quit...")

源代码网整理以下While (True)
" Accept will block until someone connects
Dim s As Socket = tcpl.Accept()

源代码网整理以下" Get the current date and time then concatenate it
" into a string
now = DateTime.Now
strDateLine = now.ToShortDateString() " " now.ToLongTimeString()

源代码网整理以下" Convert the string to a Byte Array and send it
Dim byteDateLine() As Byte = ASCII.GetBytes(strDateLine.ToCharArray())
s.Send(byteDateLine, byteDateLine.Length, 0)
Console.WriteLine("Sent " strDateLine)
End While
End Sub
End Class



源代码网推荐

源代码网供稿.
网友评论 (0)
会员中心
网络编程
本站推荐
网络编程之精华