by Lightning_Storm (4 Submissions)
Category: Internet/HTML
Compatability: VB 6.0
Difficulty: Unknown Difficulty
Originally Published: Mon 11th December 2000
Date Added: Mon 8th February 2021
Rating: (1 Votes)
This is a server aplication to make a chat, using Winsock you can send and receive messages and see the "status" of the client.There is no
API Declarations
'Programa criado por Lightning Storm em 11/11/2000 (dd/mm/yyyy)
'Uso liberado para qualquer fim
Dim Resposta As Byte
Dim BytesRecebidos As Long
Dim BytesEnviados As Long
If WskServidor.State = sckConnected Then
'envia dados digitados no campo
WskServidor.SendData txtEnviar.Text
BytesEnviados = BytesEnviados + 1
StatusBar1.Panels(3).Text = "Tx: " & BytesEnviados
txtEnviar.Text = ""
Else
Resposta = MsgBox("Vc não esta conectado no momento!.Deseja ouvir a porta", vbYesNo, "Status")
If Resposta = vbYes Then
WskServidor.Close
WskServidor.Listen
Else
WskServidor.Close
Exit Sub
End If
End If
End Sub
Private Sub cmdOuvir_Click()
'verifica estado do socket se estiver fechado passa a ouvir
If WskServidor.State = sckClosed Then
cmdOuvir.Caption = "Ouvindo..."
'especifica a porta a ouvir
WskServidor.LocalPort = CInt(txtPorta.Text)
'aciona o event de wait connect
WskServidor.Listen
StatusBar1.Panels(1).Text = "Ouvindo"
Else
'se ja estiver ouvindo dispara mensagem de aviso
Resposta = MsgBox("Servidor já esta ouvindo a porta indicada. Deseja finalizar escuta?", vbYesNo, "Aviso de Comunicação")
If Resposta = vbYes Then
WskServidor.Close
cmdOuvir.Caption = "Ouvir"
StatusBar1.Panels(1).Text = "Desconectado"
Exit Sub
End If
End If
End Sub
Private Sub Form_Load()
'pega ip local da maquina
txtIP.Text = WskServidor.LocalIP
'dipara timer
Timer1.Enabled = True
End Sub
Private Sub mnuAbout_Click()
'exibe info sobre Lightning Storm
frmAbout.Show (1)
End Sub
Private Sub Timer1_Timer()
'verifica estado do socket em 1000/ms
If WskServidor.State = sckConnected Then
StatusBar1.Panels(1).Text = "Conectado"
End If
If WskServidor.State = sckListening Then
StatusBar1.Panels(1).Text = "Ouvindo"
cmdOuvir.Caption = "Ouvindo..."
End If
If WskServidor.State <> sckConnected And _
WskServidor.State <> sckListening Then
StatusBar1.Panels(1).Text = "Desconectado"
End If
StatusBar1.Panels(4).Text = "Hora Atual: " & Time
End Sub
Private Sub WskServidor_ConnectionRequest(ByVal requestID As Long)
'Veriica se a porta esta fechada, se não fecha
If WskServidor.State <> sckClosed Then _
WskServidor.Close
'Espera solicitação de conec
WskServidor.Accept requestID
End Sub
Private Sub WskServidor_DataArrival(ByVal bytesTotal As Long)
'Recebe dados enviados por cliente
Dim strRecebe As String
WskServidor.GetData strRecebe
BytesRecebidos = BytesRecebidos + 1
StatusBar1.Panels(2).Text = "Rx: " & BytesRecebidos
txtReceber.Text = strRecebe
End Sub
******************************************************
'frmAbout
Private Sub cmdOK_Click()
Unload Me
End Sub
No comments have been posted about This is a server aplication to make a chat, using Winsock you can send and receive messages and see. Why not be the first to post a comment about This is a server aplication to make a chat, using Winsock you can send and receive messages and see.