Ну наконецно просветление ! Буду искать !
Max! писал(а):To GRS так ты кинешь ???
Attribute VB_Name = "Winsock"
Public Declare Function WSAStartup Lib "wsock32.dll" (ByVal wVersionRequested As Integer, lpWSAData As WSADATA) As Long
Public Declare Function WSACleanup Lib "wsock32.dll" () As Long
Public Declare Function gethostbyname Lib "wsock32.dll" (ByVal Name As String) As Long
Public Declare Function htons Lib "wsock32.dll" (ByVal hostshort As Integer) As Integer
Public Declare Function socket Lib "wsock32.dll" (ByVal af As Long, ByVal prototype As Long, ByVal protocol As Long) As Long
Public Declare Function connect Lib "wsock32.dll" (ByVal s As Long, Name As SOCKADDR, ByVal namelen As Long) As Long
Public Declare Function Send Lib "wsock32.dll" Alias "send" (ByVal s As Long, buf As Any, ByVal Length As Long, ByVal flags As Long) As Long
Public Declare Function Recv Lib "wsock32.dll" Alias "recv" (ByVal s As Long, buf As Any, ByVal Length As Long, ByVal flags As Long) As Long
Public Declare Function closesocket Lib "wsock32.dll" (ByVal s As Long) As Long
Public Declare Sub CopyMemory Lib "kernel32.dll" Alias "RtlMoveMemory" (Destination As Any, Source As Any, ByVal Length As Long)
Public Declare Function GetComputerName Lib "kernel32.dll" Alias "GetComputerNameA" (ByVal lpBuffer As String, nSize As Long) As Long
Public Type WSADATA
wVersion As Integer
wHighVersion As Integer
szDescription As String * 257
szSystemStatus As String * 129
iMaxSockets As Long
iMaxUdpDg As Long
lpVendorInfo As Long
End Type
Public Type HOSTENT
h_name As Long
h_aliases As Long
h_addrtype As Integer
h_length As Integer
h_addr_list As Long
End Type
Public Type SOCKADDR
sin_family As Integer
sin_port As Integer
sin_addr As Long
sin_zero As String * 8
End Type
Public Const AF_INET = 2
Public Const SOCK_STREAM = 1
Dim wsockinfo As WSADATA ' info about Winsock
Dim sock As Long ' descriptor of the socket to use
Dim RetVal As Long ' generic return value
Dim pHostinfo As Long ' pointer to info about the server
Dim hostinfo As HOSTENT ' info about the server
Dim pIPAddress As Long ' pointer to server's IP address
Dim ipAddress As Long ' server's IP address
Dim sockinfo As SOCKADDR ' info about the socket
Dim Buffer As String ' communications buffer
Dim reply As String ' reply from server
Public Function GetCompName() As String
Dim compname As String * 255 ' string to use as buffer
Dim RetVal As Long ' return value
'compname = Space(255) ' set a large enough buffer for the computer name
RetVal = GetComputerName(compname, 255) ' get the computer's name
' Remove the trailing null character from the strong
GetCompName = Left(compname, InStr(compname, vbNullChar) - 1)
End Function
Public Function MAKEWORD(ByVal bLow As Byte, ByVal bHigh As Byte) As Integer
MAKEWORD = Val("&H" & Right("00" & Hex(bHigh), 2) & Right("00" & Hex(bLow), 2))
End Function
Public Sub SockCleanUp()
RetVal = closesocket(sock)
RetVal = WSACleanup()
End Sub
Public Function SockConnect(ServName As String, ServPort As Integer) As Long
' Make the connection to the remote computer.
pHostinfo = gethostbyname(ServName)
If pHostinfo = 0 Then
SockCleanUp
SockConnect = 1
Exit Function
Else
CopyMemory hostinfo, ByVal pHostinfo, Len(hostinfo)
If hostinfo.h_addrtype <> AF_INET Then
SockCleanUp
SockConnect = 1
Exit Function
Else
CopyMemory pIPAddress, ByVal hostinfo.h_addr_list, 4
CopyMemory ipAddress, ByVal pIPAddress, 4
' Create a socket to use for the TCP/IP connection.
sock = socket(AF_INET, SOCK_STREAM, 0)
If sock = &HFFFFFFFF Then
SockCleanUp
SockConnect = 1
Exit Function
Else
End If
End If
End If
With sockinfo
' Use the IP protocol family.
.sin_family = AF_INET
' Connect to the servers port as specified with ServPort.
.sin_port = htons(ServPort)
' IP address of the server to connect to.
.sin_addr = ipAddress
' Dummy data that isn't used.
.sin_zero = String(8, vbNullChar)
End With
RetVal = connect(sock, sockinfo, Len(sockinfo))
If RetVal <> 0 Then
SockCleanUp
End If
SockConnect = RetVal
End Function
Public Function SockInit() As Long
' Initalise the sockets
RetVal = WSAStartup(MAKEWORD(2, 2), wsockinfo)
If RetVal <> 0 Then
End If
SockInit = RetVal
End Function
Public Function SockRecvData() As String
reply = ""
Buffer = Space(1024) ' read in 1 KB chunks
Do
RetVal = Recv(sock, ByVal Buffer, Len(Buffer), 0)
reply = reply & Left(Buffer, RetVal)
Loop Until RetVal = 0 Or InStr(1, reply, vbCrLf) <> 0
SockRecvData = reply
End Function
Public Function SockSendData(Buffer As String) As Long
SockSendData = Send(sock, ByVal Buffer, Len(Buffer), 0)
End Function
...Насчет пинга, так это простой эхо запрос. Был на форуме такой вопрос. Я даже пример публиковал, но так как я переехал на новый хостинг, то пример находится в другом месте: http://kilograf.km.ru/page.php?id=10
Max! писал(а):...Насчет пинга, так это простой эхо запрос. Был на форуме такой вопрос. Я даже пример публиковал, но так как я переехал на новый хостинг, то пример находится в другом месте: http://kilograf.km.ru/page.php?id=10
Там идёт уже готовый пакет мы указываем только адрес пенгуемого ! А мне нужно ВЕСь Пакет ФОрмировать и ПАТОМ СЛАТЬ !
И возможно ли перехватывать пакеты !
Сейчас этот форум просматривают: AhrefsBot и гости: 15