【正文】
Dim user() As String 39。 sckServer(FindSckIndex(())).RemotePort End Sub Private Sub sckBusy_Close() End Sub Private Sub sckBusy_DataArrival(ByVal bytesTotal As Long) SystemOrder:服務(wù)器忙,請(qǐng)稍后再連接! DoEvents End Sub Private Sub sckListen_ConnectionRequest(ByVal requestID As Long) Dim i As Integer 39。Exit Sub 39。 user(index) amp。利用winsock的State屬性給所有連接在服務(wù)器上的客戶(hù)發(fā)消息Private Sub SendToAll(msg As String) For i = 0 To MaxChan 1 If sckServer(i).State = 7 Then sckServer(i).SendData Trim(msg) DoEvents End If Next iEnd Sub39。 zxrs amp。 user(index) amp。 \) MsgBox (!) Else MsgBox (,安裝失敗!) End IfEnd IfEnd SubPrivate Sub Image1_Click()End SubPrivate Sub SetIP_Click() End Sub:服務(wù)器IP設(shè)置窗體Private Sub cmdOK_Click() WriteServerIP () Unload MeEnd SubPrivate Sub Command1_Click()Unload MeEnd SubPrivate Function WriteServerIP(filename As String) As String Dim ss As String Open filename For Output As 1 Write 1, Close 1 End FunctionPrivate Sub Form_Load() = ReadServerIP()End Sub:客戶(hù)端聊天室窗體Dim n As IntegerDim Hig As LongDim con As IntegerPrivate Sub ConnectServer()On Error GoTo ErrorPro Exit SubErrorPro: MsgBox 服務(wù)器未開(kāi)或網(wǎng)絡(luò)出錯(cuò)! EndEnd Sub Private Sub cmdSend_Click() Dim recUser As String If n 1 Then recUser = If 所有人 Then recUser = amp。 DoEvents Else amp。 DoEvents End If = Else = MsgBox 很抱歉,你被管理員禁言! End If End SubPrivate Sub cmdCls_Click() = = 4680 = 50 = 19 = 19 Hig = 19 con = 0End SubPrivate Sub cmdExit_Click() Unload MeEnd SubPrivate Sub Command1_Click() End Sub Private Sub Form_Load() = userName Hig = 19 39。 amp。 Chr(10)End SubPrivate Sub Timer1_Timer()If connecting_Time connect_OutTime Then connecting_Time = connecting_Time + 1 Exit Sub End If If = 7 Then = False Exit Sub Else Unload Me MsgBox 連接服務(wù)器失??!, 0 + 16 + 0, 聊天室客戶(hù)端 = True End IfEnd SubPrivate Sub VScroll1_Change()ChangHeight = Hig = + ChangHeight * (4560 / 19)Hig = End Sub:模塊Public userName As StringPublic Msgnum As IntegerPublic ServerIP As StringPublic connecting_Time As IntegerPublic connect_OutTime As IntegerPublic Function ReadServerIP(filename As String) As String Dim ss As String cs = ss = Open filename For Input As 1 Line Input 1, ss Close 1 ReadServerIP = Mid(ss, 2, Len(ss) 2)End Function。Unload Me Exit Sub End If If InStr(1, s, SystemOrder:addtolist) = 1 Then s = Right(s, Len(s) 21) 39。 recUser amp。 recUser amp。設(shè)置用戶(hù)狀態(tài)為離線(xiàn) Call AddToText1(S) End IfEnd Sub:模塊Public MaxChan As Integer 客戶(hù)端:登錄窗體Dim fso As New FileSystemObjectDim fil As FilePrivate Sub Command1_Click() ServerIP = ReadServerIP() userName = Trim() If userName = Then MsgBox 姓名不能為空! Exit Sub End If Load frmClient = FalseEnd SubPrivate Sub Form_Load() Dim filepath As String sysfilepath = (1)If (sysfilepath amp。 user(index) amp。State0 非正常終止 Dim S As String sckServer(index).Close If userState(index) 0 Then zxrs = zxrs 1 39。將所發(fā)信息也寫(xiě)入服務(wù)器 Call AddToText1(S)End SubPrivate Sub sckServer_Error(index As Integer, ByVal Number As Integer, Description As String, _ ByVal Scode As Long, ByVal Source As String, ByVal HelpFile As String, ByVal HelpContext As _Long, CancelDisplay As Boolean) userState(index) = 4 39。 zxrs amp。If checkUserIP(senIP) = 1 Then 39。 S Call AddToText1(S) End Sub Private Sub Form_Load() ReDim userState(MaxChan) ReDim user(MaxChan) ReDim userIP(MaxChan) Dim i As Integer Hig = 24 zxrs = 0 For i = 1 To MaxChan 1 Load sckServer(i) Next i = 1000 所有人 = 0 End SubPrivate Sub HScroll1_Change() = 50 * 10End SubPrivate Sub List1_Click() MsgBox sckServer(FindSckIndex(())).RemoteHostIP amp。 }} 網(wǎng)絡(luò)即時(shí)通訊程序 服務(wù)器端:登錄窗體Dim fso As New FileSystemObjectDim fil As FilePrivate Sub Command1_Click() MaxChan = Val()If MaxChan 1 Or MaxChan 100 Then = Else Unload MeEnd If End SubPrivate Sub Form_Load()Dim filepath As String sysfilepath = (1)If (sysfilepath amp。 a=wsfront。Y39。 if(err==0)printf(接收窗口已空,沒(méi)有接受的幀!\n)。 if(frame!=0) { err=SEND(ws,wr,frame)。 while(awsrear) { if(wss[a].timeout==6) { wss[a].timeout=1。 printf(程序開(kāi)始運(yùn)行\(zhòng)n)。n39。 } printf(\n)。 return 1。 if(wsfront==wsrear) return 0。 printf(第%d幀出接收窗口,向發(fā)送窗口返回確認(rèn)。 wsrear=(wsrear+1)%MAXSIZE。 /*發(fā)送窗口已滿(mǎn)*/ if(wsfront==wsrear) /*若窗口為空,則直接進(jìn)入*/ { wss[wsrear].snum=f