Is anyone feeling generous enough to help me finish this function? All I
seem to be able to do is achieve a 10014 error.
Also, if I understand it correctly, I have to send a string of zeros at
some point, but a series of zeros always seems to be sent as just one.
------------------------------------------
The current project can be found here:
[fxwkrver]
http://www.realsoftware.com/feedback/viewreport.php?reportid=fxwkrver
------------------------------------------
// 10014
// WSAEFAULT - Error 10014
// Question/Problem: Bad Address.
// Answer/Solution: The system detected an invalid address in
attempting to use an argument of a call.
// http://support.ipswitch.com/kb/WSK-19980714-EM04.htm
// http://www.bookmark-master.com/socket-error-10014.html
Function portFree(port As Integer) As Boolean
'http://msdn.microsoft.com/library/default.asp?url=/library/en-us/winsock/winsock/bind_2.asp
'http://www.vbip.com/winsock-api/listen-accept/listen-accept-01.asp
'http://www.vbcity.com/forums/topic.asp?tid=28254
Const AF_INET = 2
Const SOCK_STREAM = 1
Const IPPROTO_TCP = 6
Const SOMAXCONN = &H7FFFFFFF
Dim lngRetValue As Integer
Dim bindResult As Integer
Dim listenResult As Integer
Dim closeResult As Integer
Declare Function WSAGetLastError Lib "WSOCK32.DLL" () As Integer
Declare Function htons Lib "ws2_32.dll" (hostshort As Integer) As Integer
Declare Function inet_addr Lib "ws2_32.dll" (cp As CString) As Integer
Declare Function socket Lib "ws2_32.dll" _
(af As Integer, s_type As Integer, Protocol As Integer) As Integer
Declare Function bind Lib "ws2_32.dll" _
(s As Integer, name as sockaddr_in, namelen As Integer) As Integer
Declare Function listen Lib "ws2_32.dll" _
(s As Integer, backlog As Integer) As Integer
Declare Function closesocket Lib "ws2_32.dll" _
(s As Integer) As Integer
'Public Type sockaddr_in
' sin_family As Integer
' sin_port As Integer
' sin_addr As Long
' sin_zero(1 To 8) As Byte
'End Type
lngRetValue = socket(AF_INET, SOCK_STREAM, IPPROTO_TCP)
txtResult1.Text = CStr(lngRetValue)
Dim t1 As in_addr
t1.s_addr = inet_addr(txtIP.Text)
Dim t2 As sockaddr_in
t2.sin_family = AF_INET
t2.sin_port = Val(txtPort.Text)
t2.sin_addr = t1
t2.sin_zero = Val(txtZero.Text)
bindResult = bind(lngRetValue, t2, 9)
// 10014
// WSAEFAULT - Error 10014
// Question/Problem: Bad Address.
// Answer/Solution: The system detected an invalid address in
attempting to use an argument of a call.
// http://support.ipswitch.com/kb/WSK-19980714-EM04.htm
// http://www.bookmark-master.com/socket-error-10014.html
Dim iii AS Integer
iii = WSAGetLastError()
txtResult2.Text = CStr(iii)
txtResult3.Text = "Bind result: " + CStr(bindResult)
listenResult = listen(lngRetValue, SOMAXCONN)
closeResult = closesocket(lngRetValue)
'Return a default value for now
Return False
End Function
_______________________________________________
Unsubscribe or switch delivery mode:
<http://www.realsoftware.com/support/listmanager/>
Search the archives of this list here:
<http://support.realsoftware.com/listarchives/lists.html>