Tutorials to .com

ASP.NET Development Articles

Can't Find What You're Looking For?

Tutorials to .com » Dotnet » Development » vb7 in asp.net how to use the socket in a transmission time of serv

vb7 in asp.net how to use the socket in a transmission time of serv

Print View , by: iSee ,Total views: 6 ,Word Count: 316 ,Date: Sun, 23 Aug 2009 Time: 4:06 PM

/ *
Bean production, are products
technical points such as tofu http://www.asp888.net reprint please specify the source
* /

Socket can use to prepare a client to send to the time of a program, and now he can only to send the client a fixed time, a few days I intend to write a browser can be transmitted to the time of a program at any time please pay attention to my site the update. . .
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 ( "Hellon")
End Sub

Public Shared Sub Main ()
Dim now As Date
Dim strDateLine As String
Dim ASCII As Encoding = Encoding.ASCII

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

Author: tofu ()


Rating: Not yet rated


No comments posted.