动网论坛,站长建站首选,国内使用量最多的论坛软件 动网论坛官方技术讨论区 站长工具 申请属于您自己的免费论坛
首页 | 新闻资讯 | 网站运营 | 网络编程 | 数据库 | 服务器 | 网页设计 | 图像媒体 | 网络应用 | 搜索优化 | 资源下载 | 动网主机 | DVBOX
    本站内  互联网 ASP论坛  ASP.Net论坛  PHP论坛
   .Net → 阅读文章

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

作者来源: 
阅读 3310 人次 , 2000-12-5 

/*
豆腐制作,都是精品
http://www.asp888.net 豆腐技术站
如转载 请注明出处
*/

利用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\n")
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

作者:豆腐()


  

 本文TagsC#  
 收藏本文  打印本文  论坛讨论  关闭窗口
· 上一篇:asp+发送Email完全手册
· 下一篇:asp.net中的vb7中如何调用dll中的函数
· OO,OO以后,及其极限(5)
· .NET之ASP Web Application快速入门(5)
· 细细品味ASP.NET(四)
· 十天学会ASP.net(3)
· 挤压造型Extrusion的节点说明和应用实例


关于本站 | 联系我们 | 业务合作 | 客户案例 | 诚聘英才 | 广告合作 | 收藏本站
海口动网先锋网络科技有限公司版权所有
Copyright © 2000 - 2006 Cndw.Com
中华人民共和国电信与信息服务业务经营许可证编号 琼 ICP 020077