Visual Basic Examples

ChilkatHOMEAndroid™ASPVisual BasicVB.NETC#iOS (IPhone)Objective-CC++CMFCDelphiFoxProJavaPerl
PHP ExtensionPHP ActiveXPythonPowerShellRubySQL ServerVBScript

VB Examples

Bounced Mail
Bz2
Character Encoding
CSV
Digital Certificates
Digital Signatures
Email
FTP
HTML Conversion
HTTP
IMAP
Encryption
MHT / HTML Email
POP3
RSA
S/MIME
SFTP
SMTP
Socket
Spider
SSH
SSH Key
SSH Tunnel
String
Tar
Upload
XML
XMP
Zip Compression

More Examples...
Amazon S3
Email Object
DKIM / DomainKey
NTLM
DH Key Exchange
DSA
FileAccess
RSS
Atom
Self-Extractor
Service
Bzip2
PPMD
Deflate
LZW


VB Strings
VB Byte Array

 

 

 

 

 

 

 

Send File over Socket

Demonstrates how to send a file over a TCP/IP socket.

Download Chilkat FileAccess ActiveX (freeware)

Download Chilkat Socket ActiveX

Dim socket As New ChilkatSocket

Dim success As Long
success = socket.UnlockComponent("Anything for 30-day trial")
If (success <> 1) Then
    MsgBox "Failed to unlock component"
    Exit Sub
End If

Dim fac As New CkFileAccess

'  We'll send a GIF file.  First get the size of the file:
Dim fileSize As Long
fileSize = fac.FileSize("dude.gif")
If (fileSize < 0) Then
    MsgBox "Failed to get file size"
    Exit Sub
End If

'  Load the file into memory:
Dim fileData() As Byte
fileData = fac.ReadEntireFile("dude.gif")

'  Connect to the program at some host:port that is expecting
'  to receive the file.  In this case, the receiver is at
'  localhost:5555
Dim ssl As Long
ssl = 0
Dim maxWaitMillisec As Long
maxWaitMillisec = 20000
success = socket.Connect("localhost",5555,ssl,maxWaitMillisec)
If (success <> 1) Then
    MsgBox socket.LastErrorText
    Exit Sub
End If

'  Set maximum timeouts for reading an writing (in millisec)
socket.MaxReadIdleMs = 10000
socket.MaxSendIdleMs = 10000

'  Send the byte count:
success = socket.SendCount(fileSize)
If (success <> 1) Then
    MsgBox socket.LastErrorText
    Exit Sub
End If

'  Send the file data.
success = socket.SendBytes(fileData)
If (success <> 1) Then
    MsgBox socket.LastErrorText
    Exit Sub
End If

'  Close the connection with the server
'  Wait a max of 20 seconds (20000 millsec)
socket.Close 20000

© 2000-2012 Chilkat Software, Inc. All Rights Reserved.