vb@rchiv
VB Classic
VB.NET
ADO.NET
VBA
C#
Zippen wie die Profis!  
 vb@rchiv Quick-Search: Suche startenErweiterte Suche starten   Impressum  | Datenschutz  | vb@rchiv CD Vol.6  | Shop Copyright ©2000-2025
 
zurück

 Sie sind aktuell nicht angemeldet.Funktionen: Einloggen  |  Neu registrieren  |  Suchen

Fortgeschrittene Programmierung
Re: Okay hier is der ganze Source 
Autor: NightmareX
Datum: 11.11.01 20:54

Hier nun der ganze source.....
(aber ich möchte eigenltich eh nur den teil erklärt bekommen, bei dem die datei ausgelesen wird,den rest kapier ich eigentlich eh)...thx..NightmareX

Private Sub Btn_Send_Click()
On Error GoTo ErrorHandler:

Dim StartTime As Long

'You are looking for the remoteadress

'the following routines are nessessary to beware of errors
If Winsock_Send.State <> sckClosed Then '# Reset if winsock was in use
Winsock_Send.Close
End If
Winsock_Send.Protocol = sckTCPProtocol '# We work with TCP now
Winsock_Send.LocalPort = 0 '# The Localport can be a free port and unknow by you because you just need it to initialize
'# Init the Winsock
If Txt_Port.Text <> 0 Then '# select the port you entered
Winsock_Send.RemotePort = Txt_Port.Text '# set the winsock send remoteport; on the same port the client should listen already
Winsock_Send.RemoteHost = Txt_RemoteIP.Text '# that should be the same ip the client uses (Local 127.0.0.1)
Else
MsgBox "Select a Port first!"
Exit Sub
End If
Winsock_Send.Connect '# connecting to port
Lbl_Status.Caption = Winsock_Send.State & " to port: " & Winsock_Send.RemotePort

StartTime = Timer

Do While Winsock_Send.State <> 7 And Timer - StartTime < 30
DoEvents '# Wait until the connections ethablishes
Loop ' there must be a timeout check else it will never end

If Timer - StartTime > 30 Then GoTo Timeout '# When Timeout




'-----------------------------------------------------
'# Now we come to the send routine
'# You have to open a file in binary mode, read out 2k packages and send them to the connected port
'# Letz start


Dim OpenedFileNbr, FileLength, Back
Dim Temp As String
Dim PackageSize As Long
Dim LastData As Boolean

FileLength = FileLen(Txt_File.Text)
FileBar.Max = FileLength
FileBar.Value = 0


Winsock_Send.SendData ("FILEINFO|" & FileLength & "|" & Lbl_FileName.Caption & "|") '# You can add more like filename , description ...

StartTime = Timer

Do While NextPart = False And Timer - StartTime < 30 '# When the next Package where not send the procedure will quit after 30 secs timeout
DoEvents
Loop

If Timer - StartTime > 30 Then GoTo Timeout '# When Timeout

PackageSize = 2048 '# Declare the size of the packages to send
'On Error GoTo ErrorHandler

LastData = False '# You'll see that we need that to make the received
' file excactly the same size like the original one
NextPart = True '# NextPart is a form-global variable which
' contains wheter the package was send or not
' take a look at the winsock_sendcomplete event

OpenedFileNbr = FreeFile '# Find a free Filenumber to open your file
Open Txt_File.Text For Binary Access Read As OpenedFileNbr

FileLength = FileLen(Txt_File.Text)
Temp = ""
Do Until EOF(OpenedFileNbr)
' Adjust PackageSize at end so we don't read too much data
If FileLength - Loc(OpenedFileNbr) <= PackageSize Then
PackageSize = FileLength - Loc(OpenedFileNbr) + 1
LastData = True
End If

Temp = Space$(PackageSize) '# Make string empty for data
Get OpenedFileNbr, , Temp '# Load data into string

If Winsock_Send.State <> 7 Then Exit Sub '# Checks again wether the connections exist or not
On Error Resume Next

StartTime = Timer
Do While NextPart = False And Timer - StartTime < 30 '# When the next Package where not send the procedure will quit after 30 secs timeout
DoEvents
Loop

If Timer - StartTime > 30 Then GoTo Timeout '# When Timeout

If Winsock_Send.State = 7 Then '# Check state again

If LastData = True Then
Temp = Mid(Temp, 1, Len(Temp) - 1) '# We added one byte above, which we don't wanna send
' therefore we need lastdata
End If
FileBar.Value = FileBar.Value + Len(Temp)
Lbl_Complete.Caption = "Complete: " & Int(100 / FileLength * FileBar.Value) & " %"
DoneBytes = DoneBytes + Len(Temp)
Winsock_Send.SendData Temp '# Send datapackage
NextPart = False '# Set the senddata check
Else
Exit Sub
End If
Loop

Close #OpenedFileNbr '# Last package was send, now you can close the file
FileBar.Value = 0
Do While NextPart = False '# You have to wait until the sendprogress is done because
DoEvents ' when we close the winsock before the file was send completly
Loop ' data will be lost --> We use the close event in the client to
' close the received file too

Winsock_Send.Close
Exit Sub
Timeout:
MsgBox "Timeout" '# write what you want to say to the user

'# Quit
'-----------------------------------------------------
Exit Sub

ErrorHandler:
MsgBox Err.Description, vbCritical
End Sub
alle Nachrichten anzeigenGesamtübersicht  |  Zum Thema  |  Suchen

 ThemaViews  AutorDatum
Übersetzer gesucht....dringend!!!!76NightmareX11.11.01 13:38
Re: Übersetzer gesucht....dringend!!!!277unbekannt11.11.01 19:44
Re: Okay hier is der ganze Source61NightmareX11.11.01 20:54

Sie sind nicht angemeldet!
Um auf diesen Beitrag zu antworten oder neue Beiträge schreiben zu können, müssen Sie sich zunächst anmelden.

Einloggen  |  Neu registrieren

Funktionen:  Zum Thema  |  GesamtübersichtSuchen 

nach obenzurück
 
   

Copyright ©2000-2025 vb@rchiv Dieter Otter
Alle Rechte vorbehalten.
Microsoft, Windows und Visual Basic sind entweder eingetragene Marken oder Marken der Microsoft Corporation in den USA und/oder anderen Ländern. Weitere auf dieser Homepage aufgeführten Produkt- und Firmennamen können geschützte Marken ihrer jeweiligen Inhaber sein.

Diese Seiten wurden optimiert für eine Bildschirmauflösung von mind. 1280x1024 Pixel