WinSock Connection Request Error!
When I use this code for a winsock connection request:
Code: Private Sub Winsock1_ConnectionRequest(ByVal requestID As Long) Winsock1.Accept requestID txtRecive.Text = txtRecive.Text & vbCrLf & "ChatX: Connection Request Detected." End Sub
I get runtime error 40020: Invalid operation at current state
when I hit debug it highlights that code snippet up there! HELP
View Complete Forum Thread with Replies
See Related Forum Messages: Follow the Links Below to View Complete Thread
Winsock Array Connection Request
i made a post a couple days back gavino answered
im trying to make my multi chat program and well, it isnt goin by too well. for starters the client cant connect
Code:
Private Sub sckSocket_ConnectionRequest(Index As Integer, ByVal requestID As Long)
SockNum = SockNum + 1
Load sckSocket(SockNum)
sckSocket(SockNum).Listen
sckSocket(SockNum).Accept requestID
End Sub
is there sumthing wrong with that?
Winsock Server Connection Request Problem
hey, this is my code
Code:
Private Sub wskServer_ConnectionRequest(ByVal requestID As Long)
Dim msgboxResult
msgboxResult = MsgBox("A connect request has been initiated by: " & wskServer.RemoteHostIP & vbNewLine & "Would you like to accept it?", vbYesNo, "Connection Request")
If msgboxResult = vbYes Then
wskServer.Accept requestID
isServer = True
End If
End Sub
now the problem is, whenever i run it, and have a client try to connect to it, this is the error the server gives me on this line "wskServer.Accept requestID"
---------------------------
Project1
---------------------------
Run-time error '40020':
Invalid operation at current state
---------------------------
OK
---------------------------
can someone help?
EDIT: and yes, i did try:
wskServer.Close
wskServer.Accept requestID
but it doesn't work. if u need 2 see my whole code to know whats going on, just let me know
Winsock Connection Prob: "Request To Connection Time Out".
Hi All,
I am developing chat application like Yahoo and MSN messenger. Also i have almost completed it. I have two applications one is server appliation which will be run on chat server machine. the other is client appliation which will be used at any corner of the world.
Its working fine on my network. Ya, it is also working fine over network but with some misbehaviour. Sometimesm, it allow someone to login and sometimes it doesn't and gives "Request to connection time out" error.. I can't find the reason y it is happening.
I have developed this in visual basic and used winsock control.
Connection Error Winsock API.
Im using this code here in order to connect to my server which uses Winsock.OCX file. This below code is for the client which I got off a winsock API website. What is happening that for some reason when a server is being hosted, with IP and port both open for communications (no firewall etc), the client will not connect (with code below). However it's weird when I host the server side program on my friends computer it connects fine, but when it's on a dedicated server it does not work. Is there anything here fairly obvious out of order? It sort of seems like when it's on a dedicated server with a few IP's it dosen't know which one to connect to or something even though it's specefied, im lost
Code:
Call CloseSocket(lngSocketHandle)
Let lngSocketHandle = 0
enti = ip
enti2 = port
Dim lngHostName As String
Dim udtSockaddr As SOCKADDR_IN
'Switch the socket so that it does not block.
Call ioctlsocket(lngSocketHandle, FIONBIO, 1)
'First create a new streat socket that uses the TCP protocol
Let lngSocketHandle = Socket(AF_INET, SOCK_STREAM, IPPROTO_TCP)
'Error checking
If lngSocketHandle <= 0 Then
MsgBox "Connection Failed", vbCritical
Exit Sub
End If
'Try to resolve the host name to the long address.
'This function will work if it was an IP
Let lngHostName = inet_addr(enti)
'If it didn't work...
If lngHostName <= 0 Then
'Try the gethostbyname function. This will work for aliases like "www.microsoft.com"
Let lngHostName = gethostbyname(enti)
'Some more error checking
If lngHostName <= 0 Then
MsgBox "Connection Error", vbCritical
Exit Sub
End If
End If
If Not IsNumeric(enti2) Then
MsgBox "Port Based Error", vbCritical
Exit Sub
End If
'Fill out the socket address structure to ready the connection
With udtSockaddr
Let .sin_family = AF_INET
Let .sin_addr = lngHostName
Let .sin_port = htons(CInt(enti2)) 'Remember: Network byte order
End With
'Switch the socket so that it blocks and the connect function returns straight away
Call ioctlsocket(lngSocketHandle, FIONBIO, 0)
'Call the connect function
If connect(lngSocketHandle, udtSockaddr, Len(udtSockaddr)) = -1 Then
MsgBox "Connection Error", vbCritical
Call CloseSocket(lngSocketHandle)
Exit Sub
Else
connected.Enabled = False
disconnect.Enabled = True
End If
'Switch the socket so that it does not block.
Call ioctlsocket(lngSocketHandle, FIONBIO, 1)
WinSock Connection Error
Ok....I have 2 Textboxes. Text1 is the IP which to connect to, and Textbox2 is the port.
In my 1st command button I have
Winsock1.Connect Text1.Text, Text2.Text
It was working fine for a few and now it says it's an error.
How is there an error? I see no error? I'd state the permanent IP address, but it may vary, so I'd like to keep it reading off of a target text box...
is wrong with this thing?
Winsock COnnection Error
Is there some reason that winsock could connect to the server in runtime mode but not ran from an executable???
this is my code
Code:
ws.Connect "123.456.123.456", 2400 'removed my ip for safety
The other computer says 'connection request' to me when I run this code from runtime. But then I compile it, and nothing happens!
WinSock Connection Error
Hi,
I've got my winsock progam working, except that I can connect to the server and visa-a-versa, once connected I can send my commands and data, but once I connect disconnecta and re-connect I can no long send data.
When I try to send the data after I re-connect I get a run-time errror 40002 or summit similar
any help on how to combat this would be grateful.
Studz
Winsock Syntax? (To Request A Website With The Winsock Control)
Ok, I don't know very much about Winsock and am just now starting to use it. I'm making an anonymity program that modifies referer and user agent data. I managed to find an example of how its done on planetsourcecode.com but there's a few things that aren't working.
Anyway, when this string is sent, it sends the headers and a request for index.html from the connected host (winsock1.connect domain.com 80).
GET index.html HTTP/1.0
Accept: image/gif, image/x-xbitmap, image/jpeg, image/pjpeg, application/vnd.ms-powerpoint, application/vnd.ms-excel, application/msword, application/x-comet, */*
Accept-Language: en
Accept-Encoding: gzip , deflate
Cache-Control: no-cache
Proxy-Connection: Keep-Alive
User-Agent: Whatever
Referer: www.whatever.com
But when I used the website http://ipid.shat.net/ as the domain to see if code mdified the headers or not, it directed me instead to just www.shat.net. How would a browser request information to ipid.shat.net?
Also, I noticed that by sending just that information, cookies don't work properly. What other tags do I have to add onto that for it to recieve my session information? Thanks a lot.
Winsock Connection Error :-) ReSoLvEd
I am trying to check email using the winsock control. I cannot figure why the control is not connecting. It fails in the USER function that I wrote.
VB Code:
Function ReceiveMail(ws1 As Winsock, ServerName As String, ServerPort As Integer, UserName As String, Password As String) As String Dim NumMessages As Integer Dim i As Integer Dim s() As String Dim sMsg As String Set wsck = ws1 With wsck .Close If .State = sckClosed Then .LocalPort = 0 .Protocol = sckTCPProtocol .RemoteHost = ServerName .RemotePort = ServerPort RaiseEvent Sent("Connection Requested (Remote Port 110). Waiting for mResponse.") USER UserName PASS Password NumMessages = STAT(ws1) If NumMessages > 0 Then If LIST(ws1) Then For i = 1 To NumMessages sMsg = RETR(ws1, 1) Next End If End If QUIT End If .Close End With End Function Private Function USER(UserName As String) As Boolean Dim start As Single Dim tmr As Single Dim i As Integer wsck.Connect '.Connect ServerName, ServerPort ' Start connection RaiseEvent Sent("Authenticating...") 'FAILS FAILS FAILS FAILS FAILS FAILS FAILS FAILS wsck.SendData "USER " & UserName & vbCrLf start = Timer Do While Left(mResponse, 3) <> "OK+" tmr = Timer - start If tmr > 30 Then MsgBox "USER command failed" mResponse = "" USER = False Exit Function End If Loop USER = True RaiseEvent Sent("USER Successful") mResponse = "" End Function
Winsock Error: Connection Denied: Why?
Error 10061: Creatition of the connection was with intention denied;
I do a who is query, it works on several PCs fine, on some Network Client PCs with Win 98 I get the error above.
Surfing works fine on this PCs.
Where can be the error?
Winsock Connection Error - Runtime 40006
Hey people,
I have made a software application which sends and receives through the network port. However... when the program loads and then tried to send a command i get an error, now if i trap this process with a breakpoint and keep trying it will work.
What do i need to do to get this to work first time? I am getting runtime error 40006, i am guessing the connection is not properly established?
I get the following message:
Run-time error '40006':
Wrong protocol or connection state for the request transaction or request.
This message appears as the program is trying to send the first message.
Can sometime please offer me some help/solution?
Thanks.
Winsock Problem, Error 10053, Not When Connecting, But While Connection Is Open.
Hi guys.
I have searched the site, and couldn't find something that answers my question, so here goes.
I have an application, chat, client side made with adobe flash (former macromedia flash), server side in VB6, using good 'ol winsock, the programmer nightmare...
everything works just fine, only every once in a while, not all the time but often enough to make my boss question my ability as a VB programmer, which I am not, but what ever..., an error will register in my application, error number 10053, with description "Connection is aborted due to timeout or other failure".
What can cause this? the error shows up at non regular intervals, some times when a user was connected for a few seconds, some time after an hour or more of continuous connection...
Any ideas how can this be solved/avoided?
Thanks.
Let me know if you want to see specific parts of my code, and I will post it here.
Yuval Lahav.
Winsock Error 10054: The Connection Is Reset By Remote Side
Hey all. My online game seems to be screwing up whenever a winsock encounters error 10054. Standard "An error has occured, [program] will now exit" box. All socket errors are handled by simply disconnecting the player and resetting all the associated variables. However, my debug log shows that the disconnect procedure completely finished before the error occured. Here's my Error code, but I don't think it matters.
Code:
Private Sub ClientSocket_Error(Index As Integer, ByVal Number As Integer, Description As String, _
ByVal Scode As Long, ByVal Source As String, ByVal HelpFile As String, ByVal HelpContext As Long, _
CancelDisplay As Boolean)
StatusBar1.Panels(1).Text = "Error: " & Description & " on channel " & Index
On Error Resume Next
If IsLoaded(Index) Then
If Player(Index).DCReason = "" Then Player(Index).DCReason = "Socket Error: " & Description
Call DisconnectPlayer(Index) '<-- this Sub was finished before the error occured.
End If
End Sub
I doubt you guys will be able to assertain the problem just from that, but could you at least tell me how to reproduce error 10054 so I can debug it properly?
EDIT: If it matters, the error occured during heavy traffic.
Connection Request
Greetzzz,
I am working with a client and a server. There is no problem when i connect to the client , but when i close the server, and try to run it again ( button: connect) i get the error , the connection is forcefully rejected.
on the client side i have:
[vbcode]
Private Sub Winsock_ConnectionRequest(ByVal RequestID As Long)
Winsock.Close
Winsock.Accept RequestID
end sub
[/vbcode]
on the server side:
(with or without, it doesn't matter)
[vbcode]
Private Sub Form_Unload(Cancel As Integer)
Winsock.Close
End Sub
[/vbcode]
It is only when i close and rerun the client that i manage it to work
Connection Request Interception
how do i Intercept Connection Requests made by Yahoo Messenger and relay the Packets between the client and the server?
anyone?
What Happens To Clients Request Connection At The Same Time?
lets say there is one client that request a connection with a winsock at the same time or... with very small time differences... what happens to the following event:
VB Code:
Private Sub oSocket_ConnectionRequested(ByVal requestID As Long) 'lets say here I have the code 'to accept the call and pass it to another EXE process but 'before this.. another ConnectionRequest arrives.... 'will it wait until this sub is over.. or will it interrup it? end sub
Winsock Request
I have a Winsock component setup right now on my network, exact same as whats in this thread
I would like to know if a similar control can be built using Winsock to do this:
1) Connect to a remote computer, by IP address. (I have a code that determines the IP address of the remote machine already..)
2) Open a .txt file, send it back to (my) the users computer and displays it in a text box on screen.
3) On command button press, take what ever is in my text box, and send the file back to the remote computer and save it.
Kind of like editing a configuration file, remotly.
I know the application would have to be running on the remote end as well as my end for this to work, if its at all possible.
I would really like to do this, I appeciate everyones help in advance!
Winsock Example Request
I'm at work where I can't get to any help files for winsock. Can somebody give me a quick example of the code required to create a winsock instance, including telling it to listen and respont to internet requests? I'm going to attempt to make MS Access act like a simple server, and I just don't have the resources here to get it running. Thanks!
Winsock HTTP Request Help
I need help with this, my wrapper uses winsock to send requests and the close event does not fire which makes the connection stay open forever, my wrapper is at the bottom it is a attachment
WinSock Request Accept
Hey,
I have been trying to get this code to work, It's most likely something stupid am doing, but i cant get my server program type thingie to accept the Request ID from the client program thingie... Here is the code to the part that it says is wrong (If you need anyother parts tell me an i'll post it)
Code:
Private Sub HostSocket_ConnectionRequest(ByVal requestID As Long)
'Show Request In Host Log
HMsg = "Connection request id " & requestID & " from " & HostSocket.RemoteHostIP
HostLog.AddItem (HMsg)
sRequestID = requestID
iSockets = iSockets + 1
ConNumber.Caption = iSockets
Load HostSocket(iSockets)
HostSocket.LocalPort = 1007
HostSocket.Accept requestID
End Sub
PS. I looked at an example to help me with this, so am not sure whats wrong.
Thx in advance.
Ali.
Can Winsock DLL Do Other Protocol Request ...
guys,
i find that the winsock OCX really is limited in its capability...
can anyone suggest me a better one for network programming? because the protocol type is limited to a few only....
I hope to do RTSP / RTP request ... is there any thing that i can used to do that ???
can Winsock Dll do other protocol request or its the total same with the winsock OCX?
Does anyone has a sample using winsock DLL (as client)...??
Multiple Request With Winsock
Greeting,
I have a little problem with winsock. I have a server and several
client. I want to transfer text from server to client trough the network
In this case, I using winsock to transfer the text. It is ok when only 2
computer connected (1 server and 1 client). But, when 3 computer
Connected (1 server and 2 client) I cant broadcast text to all client.
Does any body know how to broadcast text fom server to client trough the
network and winsock?
thanks
Rgds,
Rano Nugrah Agung Homan
Winsock Sample Request
Hi all,
I need to make a server app for my project. I have concluded that I will need to implement Winsock to do so. I have read up on all Winsock articles here (and many others elsewhere) and have downloaded and studied all the samples I could find.
However, I am unable to do what I want because:
- The tutorials say that the IP address or friendly name of the target computer MUST be specified for the Winsock control to connect on the other side. This strikes me as very backward, as I can not always know what IP addresses my customers' network stations will be running on and cannot also predict their friendly names. Does this have to be hard-coded?
- Try as I may, I cannot create a working sample of Server.Exe and Client.Exe to run on the same machine as I cannot afford the luxury of testing my code over two machines. Is there any way I can debug / test on one machine?
If any member proficient with Winsock (Laura Stephens and Jason Rogers come to mind) would like to help, I shall appreciate a small sample to get me started by solving the above two problems.
GoodGuy
Experience is a bad teacher for its exams precede its lessons.
Edited by - GoodGuy on 12/10/2007 10:23:30 PM
[VB6] Winsock POST Request Problem
I'm trying to connecto to google.com and translate a simple word (just to test if works).
And I have a problem when I'm sending POST request data, here is my code:
Code:
Private Sub Command1_Click()
Winsock1.Close
Winsock1.Connect "www.google.com", "80"
End Sub
Private Sub Winsock1_Connect()
Dim packet As String
Dim strpost As String
strpost = "hl=it&ie=UTF8&text=hello&sl=en&sl=en&tl=it&tl=it"
packet = "POST /translate_t HTTP/1.1" & vbCrLf
packet = packet & "Host: www.google.com" & vbCrLf
packet = packet & "Accept: */*" & vbCrLf
packet = packet & "Accept-Language: it,it-it;q=0.8,en;q=0.5,en-us;q=0.3" & vbCrLf & vbCrLf
packet = packet & "Content-Type: " & "application/x-www-form-urlencoded" & vbCrLf
packet = packet & "Content-Length: " & Len(strpost) & vbCrLf
packet = packet & strpost
Winsock1.SendData packet
Text1.Text = Text1.Text & packet
End Sub
Private Sub Winsock1_DataArrival(ByVal bytesTotal As Long)
Dim data As String
Winsock1.GetData data
Text2.Text = Text2.Text & data & vbCrLf
End Sub
As you can see I want the GETDATA in Text2.Text but I recieve this error:
Code:
HTTP/1.1 411 Length Required
Date: Fri, 01 Aug 2008 13:57:24 GMT
Content-Type: text/html; charset=UTF-8
Server: GFE/1.3
Content-Length: 1357
{html code}
What's the problem?!
Thanks in advance.
Wrong Protocol Or Connection State For The Requested Transaction Or Request....
I wrote a small application. It has 2 forms, one which listens on port 5555 and one that sends to it. Form1 listens to it and expects to recieve a byte array and insert it into a udt and print out the values of the variables in the udt on a label. In Form2 the data values are inserted into a byte array which is then sent to port 5555.
When I try to run this application, I get runtime error 40006 "wrong protocol or connection state for the requested transaction or request".
Can someone please look at the code and tell me what i'm doing wrong?
Thanks.
Winsock/cookie Request Entity Too Large...
hi i'm sending a cookie header via winsock but i think it's to large cause I'm receiving a "Request Entity Too Large" in the HTTP Response. is there a way around this?
Winsock - Notification When User Accepts Request
Does anyone know of a way that an initiator of a Winsock connection can be notified when a user on the other end accepts the connection ? I'm new to Winsock, so my terminology might not be the best, but I'm trying to find out if the inititator has any way of knowing that a connection was made before any messages are exchanged?
Thanks for any help....
HELP: Winsock To Send HTTP POST REQUEST To A Machine
Hello,
I would like to use visual basic to send data to a machine using an HTTP Post request, and cannot decide on the best way to do it. Can I use winsock. Please bear in mind the following.
I am sending a mult-part message (kind of like an email with attachments). It's actually a multimedia message in the MM7 format -> this is similar to email, a multipart MIME message.
I MUST post to a destination using the following format:
http://192.168.3.75:2097/mm7
I need to then send the data which I've formated according to the MM7 spec.
I need to receive responses from the receving application.
Any help would be greatly appreciated.
Thanks
Ben
Winsock: "Connection Is Forcefully Rejected" Error
I have written two programs, a client and server program. The client connects to the server, the server sends data and then closes the connection, then goes back to listen for more connections. The client connects fine, and everything goes like it should, but when I try to connect again (without resetting the server) I get a "Connection is forcefully rejected" error. Why? The server's state is 2 (listening).
Disiance
Winsock State 8 - Peer Closes The Connection Leaving Winsock High And Dry
I am debugging some web/proxy-serving code. I am stumped.
I get Winsock state 8 - Peer is closing the connection
Then Winsock error message wrong protocol or connection state.
It seems to me that Winsock closes before it can finish sending all of its data.
How can I keep Winsock in state 7 - Connected?
Thanks...
Simple GET Request && Error
hello,
i have a question regarding a project i already finished..
i get the known error of microsoft : Don't Send or Report
when i exit the program !!!!
i have a motion detection in the main form
and it has a START & STOP Button :
this is START cam :
Code:
mCapHwnd = capCreateCaptureWindow("WebcamCapture", 0, 0, 0, 320, 240, Me.hwnd, 0)
DoEvents
SendMessage mCapHwnd, CONNECT, 0, 0 'connecting to camera
SendMessage mCapHwnd, WM_CAP_DLG_VIDEOFORMAT, 0, 0 'Calling video format dialog
DoEvents
and this is STOP cam :
Code:
DoEvents: SendMessage mCapHwnd, DISCONNECT, 0, 0
Timerx1.Enabled = False
Timerx2.Enabled = False
i have tried several times to change the way i stop CAM and searched google... seems i don't unload the device properly
whenever i click start and then stop the CAM.
if i click Exit or X or watever.. the program have to close with error..
can anybody tell me how to do Simple HTTP GET or POST request... as i want to add an SMS alert on some actions.. the sms gateway and be used with GET and POST
12002 Communication Error The Request Has Time Out In IE7
Hi,
I have made a VB application which downloads data from a server through FTP & then displays that in a proper format.
Recently I have upgraded to IE7 from IE6 now when i try to download small data its not having any problem but when i m trying to download big files its giving this 12002 Communication error.
My code is working fine since years but with IE7 its breaking for big files.
I am using wininet.dll API & InternetOpenUrl function
I am not able to figure out is it a limitation with IE7 ?
Can anybody please help me
Thanks
Pragya
Internet Transfer Control - Still Executing Last Request Error
I get Run-time error 35764 - Still executing last request error appears
when attempting to use Transfer Control.
The simple routines in use are below
I am using VB5.
Any references to this error in the knowledgebase talk about attempting to compare the StillExecuting property with True, which I am not consciusly doing.
Any thoughts on this ??
Regards
Dave Wilson
' Now Copy Output File to Web Site
Inet1.Url = Text8.Text
Inet1.UserName = txtUser.Text
Inet1.Password = txtPassword.Text
Inet1.Execute Text8.Text, "CD imi-wm/training_events/booking-forms"
Inet1.Execute Text8.Text, "DIR"
Inet1.Execute Text8.Text, "CLOSE"
Winsock Connection Prob: "Attempt To Connection Time Out".
Hi All,
I am developing chat application like Yahoo and MSN messenger. Also i have almost completed it. I have two applications one is server appliation which will be run on chat server machine. the other is client appliation which will be used at any corner of the world.
Its working fine on my network. Ya, it is also working fine over network but with some misbehaviour. Sometimesm, it allow someone to login and sometimes it doesn't and gives "Attempt to connection time out" error.. I can't find the reason y it is happening.
I have developed this in visual basic and used winsock control. Any idea regarding this may help me out.
ADO Object Or Provider Is Not Capable Of Performaing Request Operation Error
Hi all,
here is a snippet of code that produces a "Object or provider is not capable of performing requested operation" error:
Set conn = New ADODB.Connection
conn.ConnectionString = "DSN=Visual FoxPro Database;UID=;" & _
"SourceDB=" & g_"myFoxProdb.DBC;" & _
"SourceType=DBC;Exclusive=No;" & _
" BackgroundFetch=Yes;Collate=Machine;Null=Yes;Delet
ed=Yes;"
conn.Open
'Get table info from fp database
Set rsSchema = conn.OpenSchema(adSchemaTables)
Error is generated after I call OpenSchema method. I am using Microsoft ActiveX Data Object 2.6 Library.
If anybody has any deas on the nature of the problem, please help
thank you
Biasha
ADO Object Or Provider Is Not Capable Of Performaing Request Operation Error
Hi all,
here is a snippet of code that produces a "Object or provider is not capable of performing requested operation" error:
Set conn = New ADODB.Connection
conn.ConnectionString = "DSN=Visual FoxPro Database;UID=;" & _
"SourceDB=" & g_"myFoxProdb.DBC;" & _
"SourceType=DBC;Exclusive=No;" & _
"BackgroundFetch=Yes;Collate=Machine;Null=Yes;Deleted=Yes;"
conn.Open
'Get table info from fp database
Set rsSchema = conn.OpenSchema(adSchemaTables)
Error is generated after I call OpenSchema method. I am using Microsoft ActiveX Data Object 2.6 Library.
If anybody has any deas on the nature of the problem, please help
thank you
Biasha
VB & SQL Server 6.5 Error - Request Properties Cannot Be Supported By ODBC Driver
My team has built a VB interface to batch load records to a SQL Server 6.5 database on a web server we are getting the error message: The Request properties cannot be supported by this ODBC driver. error number -2147217887 or in hex 80040E21. We choose the to continue the app continues on its merry way without ever getting that error again. We are running the app over a large corporate network within our firewall. Does anyone have any suggestions or know why this might be happening?
Run Time Error 35761 Request Timed Out And 35764 Still Executing Last Requet
hi..
I ma receiving these two errors in my VB 6 application.
run time error 35761
Request timed out
Run Time error 35764
still executing last req .
Everything was working fine before we moved our database(SQL server 2000) and other files to other server. Now after moving it i am gettign this error. Is any one can help me out.
Many thanks.
Nitesha Patel
Winsock Error (System Lockup Upon Winsock Execution)
Has anyone encountered an issue when running the winsock command and either a .listen or .connect locks up your VB Studio? This is occurring on my system and I'm not sure if its a problem with my current DLL or if I'm just not doing something correctly.
Please help.
Chris, Baltimore.
Winsock Connection...
ok, im trying 2 make a little instant messenger sorta program, anyways, i have it set up with a radio button so that u either choose to accept messages (server) or send (client). When u press accept and click connect it should just set the local port on winsock1 to whatever the text box for local port is (1412 is what im using). when u press send messages and press connect, it should connect to the ip u entered using the port u entered (127.0.0.1, and 1412). Ok, now, if i make it an exe, open it twice, and set one to be the server and the other to be the client, and presss connect on both, the state of the server side is 0, and the client side goes from state 6 to state 9 (im not sure what these 2 are, but i know 7 is connected). I cant get it to connect to the other program thats open, ill post my code below... and also, if i set the local port on the winsock to port 1412 and connect to port 1412 the program works fine (im doing this without opening the program twice). and i can send messages and all, however it needs to work if some1 were to open the program on different computers. im just gonna post my code for the main form, since the other 2 just tell it to send messages (which work fine if its connected). Hopefully some1 will b able 2 help me out!
Code:
'Declare Variables
Public blnListening As Boolean
Public strMessageTaken As String
Public blnReady As Boolean
'Connect
Private Sub cmdConnect_Click()
If blnListening = True Then
Winsock1.LocalPort = txtLocalPort.Text
frmServer.Show
cmdConnect.Enabled = False
Option1.Enabled = False
Option2.Enabled = False
txtLocalPort.Enabled = False
txtName.Enabled = False
blnReady = True
End If
If blnListening = False Then
Winsock1.LocalPort = "0"
frmClient.Show
cmdConnect.Enabled = False
Option1.Enabled = False
Option2.Enabled = False
txtIP.Enabled = False
txtPort.Enabled = False
txtName.Enabled = False
Winsock1.Connect txtIP.Text, txtPort.Text
blnReady = True
End If
End Sub
'Close Connection
Private Sub Close_Click()
Winsock1.Close
frmClient.Hide
frmServer.Hide
cmdConnect.Enabled = True
Option1.Enabled = True
Option2.Enabled = True
txtIP.Enabled = True
txtPort.Enabled = True
txtLocalPort.Enabled = True
txtName.Enabled = False
blnReady = False
End Sub
'Load Form
Private Sub Form_Load()
Winsock1.Close
If Option2.Value = True Then
blnListening = False
Else
blnListening = True
End If
txtName.Text = Winsock1.LocalHostName
End Sub
'Exit
Private Sub Label8_Click()
Unload frmClient
Unload frmServer
Unload frmConnection
End Sub
'Listening Options:
'xxxxxxxxxx
Private Sub Option1_Click()
If Option2.Value = True Then
blnListening = False
Else
blnListening = True
End If
End Sub
Private Sub Option2_Click()
If Option2.Value = True Then
blnListening = False
Else
blnListening = True
End If
End Sub
'xxxxxxxxxx
'Peridoc1
Private Sub Timer1_Timer()
frmConnection.Caption = "Connection: " + LTrim$(Winsock1.State)
lblYourIP.Caption = RTrim$("Your IP: ") + Winsock1.LocalIP
End Sub
'Connection Request
Private Sub Winsock1_ConnectionRequest(ByVal requestID As Long)
If blnReady = True Then
Winsock1.Accept requestID
Winsock1.Listen
If Winsock1.State = 7 Then
frmServer!rtbMessages.Text = "Connected!"
frmClient!rtbMessages.Text = "Connected!"
End If
End If
End Sub
'Receive Data
Private Sub Winsock1_DataArrival(ByVal bytesTotal As Long)
If blnListening = True Then
Winsock1.GetData strMessageTaken
frmServer!rtbMessages.Text = frmServer!rtbMessages.Text + strMessageTaken
End If
If blnListening = False Then
Winsock1.GetData strMessageTaken
frmClient!rtbMessages.Text = frmClient!rtbMessages.Text + strMessageTaken
End If
End Sub
Winsock TCP Connection
I need to write a little program to send Unix/linux command to a remote PC by LAN connection. I do it now by Hiperterminal and it works fine. I want to write a program to have help in this way:
in Unix/linux if I send ps -e they show me the list of the active process, if i send cd they change directory and so on..............
Now I want to log in and by pressing some botton in the main panel of my program I want to send the command.
I use the winsock and this code:
Private Sub Command1_Click()
Winsock1.Protocol = sckTCPProtocol
Winsock1.Connect Text2, Text3
End Sub
Private Sub Command2_Click()
Winsock1.Close
End Sub
Private Sub Command3_Click()
Winsock1.SendData Text4 & vbCrLf
End Sub
Private Sub Form_Load()
Dim Instringa As String
End Sub
Private Sub Winsock1_DataArrival(ByVal bytesTotal As Long)
Winsock1.GetData Instringa, vbString
Text1 = Text1 & Instringa
End Sub
Private Sub Winsock1_Error(ByVal Number As Integer, Description As String, ByVal Scode As Long, ByVal Source As String, ByVal HelpFile As String, ByVal HelpContext As Long, CancelDisplay As Boolean)
MsgBox "ERRORE : " & Description
Winsock1.Close
End Sub
When I press connect (port number 23=telnet)I see in the text1 some characters unknow like this:
ÿýÿý ÿý#ÿý'
If I change the port (21=FTP) I see the welcome message. When I use telnet by hyperterminal (by TCP Winsock on port 21)I don't have this problem......How I can translate it?
I'm sorry for my bad english .Thanks!!!
Winsock Connection Que?
Can someone give me an example of how I would make a client-server program, that the client is in a que and has to wait until its his turn?
Winsock Connection Help
i just get an overflow...
nvm i got it.
right now with this...
VB Code:
Private Sub Command1_Click()Dim x(3) As Datax(0) = &H4x(1) = &H0x(2) = &H89x(3) = &HCWinsock1.SendData (x)End Sub
this worked last time i tryed..now it wont work im sending data as u can see im sending it as HEX
and i get an error..
and... i need to connect to the server and a client..the server connect's but..the client dont for some reson..
VB Code:
Private Sub Form1_load()winsock1.remotehost = "gsproduc.ath.cx"winsock1.remoteport = 9100winsock1.connectwinsock2.remotehost = "127.0.0.1"winsock2.remoteport = 9100winsock2.connectEnd Sub
that isnt the code i have im using the simple part in the winsock control the custom thing...anyways the code i put there is just 2 tell u what i would have if i was putting it in if u get me. ok now the server connect's but the client dont...(if u must know im sending packets to a game server) this all worked out b4 i had 2 formatt my pc so if anyone can help thx alot
-infamouszero-
Winsock Connection
i'm working on networked computers and trying to connect to the computer beside mine using winsock. when my program starts my state will get to 6 (connecting) but never to 7. no matter how many times i loop through the process i can't make a connection! does anyone know why?
|