gambas-source-code/comp/src/gb.net.smtp/.src/TcpSession.class
Benoît Minisini 97913aa329 [CONFIGURATION]
* NEW: Switch to version 3.6.0.

[DEVELOPMENT ENVIRONMENT]
* BUG: Correctly reset position buttons when a project is loaded.
* BUG: Text editor: Fix word delimiter characters for automatic completion.

[GB.GUI.BASE]
* BUG: ScrollArea: Prevent a possible crash.

[GB.NET.SMTP]
* BUG: Remove a debugging message.


git-svn-id: svn://localhost/gambas/trunk@6518 867c0c6c-44f3-4631-809d-bfa615b0a4ec
2014-10-02 21:38:50 +00:00

89 lines
1.5 KiB
Text

' Gambas class file
Inherits SmtpSession
Property Read Connected As Boolean
Private $hSocket As New Socket
Public Sub _new()
'Wait 10 seconds before timing out
$hSocket.Timeout = 10000
$hSocket.EndOfLine = gb.Windows
End
Public Sub Client_Ready()
'Debug "Connected to remote host " & sSocket.Path
End
Public Sub Client_Closed()
'Debug "Connection Closed by foreign host."
End
Public Sub Client_Found()
'Debug "Host Found. Connecting..."
End
Public Sub Connect(hClient As SmtpClient, sHost As String, iPort As Integer)
If Not sHost Then sHost = "localhost"
If iPort = 0 Then iPort = 25
Super.Connect(hClient, sHost, iPort)
$hSocket.Timeout = 10000
$hSocket.Connect(sHost, iPort)
$hSocket.Blocking = True
Me.Stream = $hSocket
Do
'Print $hSocket.Status
If $hSocket.Status = Net.Connected Or If $hSocket.Status <= 0 Then Break
Wait 0.1
Loop
If $hSocket.Status < 0 Then
Select Case $hSocket.Status
Case Net.CannotCreateSocket
Error.Raise("Cannot create socket")
Case Net.HostNotFound
Error.Raise("Host not Found")
Case Net.ConnectionRefused
Error.Raise("Connection Refused")
Case Net.CannotRead
Error.Raise("Read error")
Case Net.CannotWrite
Error.Raise("Write error")
End Select
Endif
End
Public Sub Disconnect()
Try $hSocket.Close
Super.Disconnect
End
Private Function Connected_Read() As Boolean
Return $hSocket.Status = Net.Connected
End