VB6 Network Programming (Farsi) PDF
VB6 Network Programming (Farsi) PDF
TCP/IP
: . TCP/IP
.
: Protocol
: TCP/IP
. :
- : Application Layer Pop Smtp Ftp Http Telnet
.
- : Transport Layer TCP UDP . TCP
) TCP/IP
( UDP . TCP
.
- : Layer Internet IP .
- : Link Layer
.
Socket : Port TCP/IP
. TCP UDP
. :
- : initiate accpet
- :
- : IP
: HTTP .
: FTP .
SMTP : POP email .
Web Browser
- Internet Transfer
.
IT .
: GetChunk IT :
Inet.GetChunk(datasize[,datatype])x
datasize long datatype
icString icByteArray .
StateChanged icResponseReceived icResponseCompleted GetChunk
. :
Integer)x Private Sub Inet_StateChanged(Byval State as
Dim temp1,temp2
Select Case State
icResponseCompleted Case
temp1=x
temp2=x
Do
temp1=Inet.GetChunk(512,icString)x
temp1 & temp2=temp2
Loop Until temp1=x
End Select
End Sub
) 512 1024 ( .
: Execute IT Execute . :
Inet.Execute(url,Command,Data,RequestHeaders)x
url Command Data RequestHeaders
. Command HTTP :
: GET : HEAD header : POST : PUT ) ( upload GET Execute IT
GetChunk .
:
Inet.Execute http://www.microsoft.com,GETx
: IT
: AccessType IT : : icUseDefault
: icDirect IT
: icNamedProxy
: Document Execute . Execute url .
: ResponseCode icError . : ResponseInfo : StillExecuting True . : URL OpenURL Execute : UserName - FTP
- Internet Transfer
FTP
FTP ) (
FTP . HTTP HTTP
IT .
FTP Login . Login ) Anonymous Login (
FTP .
. username password
IT . username ) ( blank IT anonymous
email passowrd .
: OpenURL OpenURL FTP . FTP
:
Text.text=Inet.OpenURL("ftp://ftp.microsoft.com",icString)x
FTP :
b()=Inet.OpenURL("ftp://ftp.microsft.com/test.zip",icByteArray)x
: Execute Execute FTP :
Inet.Execute(url,operation)x
- WinSock
:
WinSock .
TCP UDP .
) Client/Server / ( TCP UDP
.
. :
Port Scanner Game Network Proxy Server Mail server Mail client Client-server chat
: TCP
) ( Transfer Control Protocol ) ( Connection )
( socket ) ( Computer Remote .
. TCP
.
Client IP Server ) ( Remote Host IP
) . ( Remote Port Connect .
Server )
( LocalPort ) . ( Listen
Client Server Accept .
.
: UDP
) ( User Datagram Protocol ) ( Connectionless . TCP
client server .
UDP .
UDP Local Port Client . Server
RemoteHost Client Remote Port Local Port Client
. .
: WinSock
1 : WinSock TCP
UDP . .
:
Server Client TCP .
) ( TCP TCP .
.
) ( Session UDP .
UDP .
2 :
Protocol WinSock sckTCPProtocol sckUDPProtocol .
:
WinSock.Protocol=sckTCPProtocol
3 : IP .
Control Panel/Network/Identification . Client Server
IP 127.0.0.1
ipconfig DOS Prompt IP .
4 : TCP TCP
Client . Server Server Listen . Client
Server Accept . Client
Server .
TCP :
Project Components Component Microsoft WinSock 6.0 .
WinSock tcpserver textbox txtSendData txtReceiveData . Form_Load :Tcpserver.LocalPort=1000
tcpserver.Listen
Client ConnectionRequest . . .
requestID :
(requestID As Long Private Sub tcpserver_ConnectionRequest(ByVal
tcpserver.Close sckClosed Then <> If tcpserver.State
tcpserver.Accept requestID
End Sub
Client Server . event Send :Tcpserver.SendData txtSendData.text
Client DataArrival . :(As Long Private Sub tcpserver_DataArrival(ByVal bytesTotal
Dim strData As String
strData tcpserver.GetData
txtReceiveData.Text = strData
End Sub
Form_Unload :Tcpserver.Close
TCP Client :
WinSock tcpclient . textbox txtsend txtreceive send . connect . Form_Load :tcpclient.RemoteHost=yourservernamex
tcpclient.RemotePort=1000
connect :tcpclient.Connect
send :tctclient.SendData txtsend.Text
DataArrival :(As Long Private Sub tcpclient_DataArrival(ByVal bytesTotal
Dim strData As String
strData tcpclient.GetData
txtreceive.Text = strData
End Sub
Form_Unload :Tcpclient.Close
Client-Server . exe
.
5 Server : .
WinSock . )
( instance ) ( Index Accept instance .
WinSock sckServer Index . intMax
Long Server . event Form_Load
:
intMax=0
sckServer(0).LocalPort=1000
sckServer(0).Listen
Index . Index
intMax intMax instance .
instance . ConnectionRequest
:
(Integer, ByVal requestID As Long Private Sub sckServer_ConnectionRequest(Index As
If Index = 0 Then
1 + intmax = intmax
Load sckServer(intmax)x
0 = sckServer(intmax).LocalPort
sckServer(Index).Accept requestID
End If
End Sub
6 : UDP UDP TCP UDP .
TCP WinSock Listen Connect
. UDP . WinSock
:
RemoteHost . RemotePort LocalPort Bind LocalPort Peer-to-Peer .
chat :
WinSock udppeerA . Protocol UDPProtocol . textbox txtsend txtreceive . Form_Load :udppeerA.RemoteHost=nameofpeerBx
udppeerA.RemotePort=1001
1002 udppeerA.Bind
event :udppeerA.SendData txtsend.text
DataArrival :Dim strData as String
strData udppeerA.GetData
txtreceive.Text=strData
- WinSock
: WinSock
: ByteReceived ) ( receive . GetData
.
: LocalHostName . .
: LocalIP IP string . .
: LocalPort .
: Protocol WinSock .
: RemoteHost IP .
: RemoteHostIP IP :
- Client Connect IP
.
- Server Connection Request IP .
- UDP Arrival Data IP
.
: RemotePort .
: SocketHandle WinSock
WinSock . API WinSock
.
: State WinSock . State :
: sckClosed - .
: sckOpen - .
: sckListening -
: sckConnectionPending - 4
: sckResolvingHost -
: sckHostResolved - .
: sckConnecting -
: sckConnected - .
: sckClosing -
: sckError -
: WinSock
: Accept TCP Server .
ConnectionRequest .
: Bind LocalPort LocalIP .
: Close TCP listening socket .
: GetData Variant .
:
WinSock.GetData data[,type][,maxlen]x
TAPI -
TAPI
TAPI Telephony API .
) Phone Dialer ( ) ( Dialup Networking
.
.
TAPI -
: Microsoft Telephony
Telephony .
) PSTN ( .
Telephony :
Multicast
VoIP
PSTN
Microsoft Telephony :
: TAPI
TAPI
. TAPI
) . ( Assisted Telephony
TAPI .
TAPI 2.x . TAPI 3.x
TAPI API C COM .
.
TAPI :
: TAPI Initialization - load TAPI dll Server TAPI TAPI
event .
: Session Control -
: Device Control -
: Media Control - stream
: TAPI Shutdown -
:
TAPI -
: TAPI
TAPI . :
- : TAPI .
.
- :
- : TAPI TAPI .
- : TAPI
.
: Event notification - event
TAPI -
TAPI :
Project References Microsoft TAPI 3.0 Type Library
.
objTAPI :
Dim objTapi As TAPI
Load Form objTAPI :
Set objTapi = New TAPI
TAPI .
TAPI :
Call objTapi.Initialize
- TAPI
:
TAPI
.
TAPI
.
error checking :
.
: -
Dim gobjAddress As ITAddress
As ITCollection Dim objCollAddresses
: objTapi objCollAddress -
Set objCollAddresses = objTapi.Addresses
: -
bFound = False
objCollAddresses.Count For indexAddr = 1 To
objCollAddresses.Item(indexAddr)x = Set objCrtAddress
Set objMediaSupport = objCrtAddress
objAddressCapabilities = objCrtAddress Set
nSelectedType ) x )If objMediaSupport.QueryMediaType
bFound = True
End If
Nothing = Set objAddressCapabilities
Set objMediaSupport = Nothing
Nothing = Set objCrtAddress
If bFound = True Then Exit For
Next indexAddr
: gobjAddress
objcollAddresses.Item(indexAddr)x = Set gobjAddress
- TAPI
- TAPI
:
TAPI Initialization +
.
: ) ( ITBasicCallControl
Dim objCallControl As ITBasicCallControl
objCallControl = gobjReceivedCallInfo Set
: ) ( ITTerminalSupport
Dim objTerminalSupport As ITTerminalSupport
objTerminalSupport = gobjAddress Set
: objTerminalSupport
Dim objTerminal As ITTerminal
objTerminalSupport.GetDefaultStaticTerminal(lMediaType, dir)x = Set objTerminal
: objTerminalSupport
Set objTerminalSupport = Nothing
: objStreamControl
Dim objStreamControl As ITStreamControl
objStreamControl = objCallControl Set
for ITCollection
:
If Not (objStreamControl Is Nothing) Then
objITCollStreams As ITCollection Dim
objStreamControl.Streams = Set objITCollStreams
: ( Make a Call )
. TAPI Initialization +
.
. TAPI Initialization
: CreateCall
nSelectedType,lMediaTypes)x ,gobjOrigAddress.CreateCall(strDestAddress = Set gobjCall
:
{
Select Terminal Code
}
: Connect
gobjCall.Connect (False)x
. False
- TAPI
:
.
. event
pEvent .
: event Handler TAPI ITCallNotificationEvent
If TapiEvent = TE_CALLNOTIFICATION Then
objCallNotificationEvent As ITCallNotificationEvent Dim
objCallNotificationEvent = pEvent Set
ITCallInfo Dim gobjReceivedCallInfo As
Set gobjReceivedCallInfo = objCallNotificationEvent.Call
objCallControl As ITBasicCallControl Dim
gobjReceivedCallInfo = Set objCallControl
objCallControl.Answer
End If
http://sheidaian.persianblog.com