Help.Tired.Annoyed.Fix. :(
Help.Tired.Annoyed.Fix. :(
Help.Tired.Annoyed.Fix. :(
Help.Tired.Annoyed.Fix. :(
Help.Tired.Annoyed.Fix. :(
Help.Tired.Annoyed.Fix. :( Help.Tired.Annoyed.Fix. :( Help.Tired.Annoyed.Fix. :( Help.Tired.Annoyed.Fix. :( Help.Tired.Annoyed.Fix. :( Help.Tired.Annoyed.Fix. :( Help.Tired.Annoyed.Fix. :( Help.Tired.Annoyed.Fix. :(
Help.Tired.Annoyed.Fix. :( Help.Tired.Annoyed.Fix. :(
Help.Tired.Annoyed.Fix. :(
Go Back  Xtreme Visual Basic Talk > > > Help.Tired.Annoyed.Fix. :(


Reply
 
Thread Tools Display Modes
  #1  
Old 03-14-2003, 12:11 AM
Latac Latac is offline
Restricted
 
Join Date: Aug 2003
Posts: 218
Default Help.Tired.Annoyed.Fix. :(


lol sorry for this post but I bin tyring to get this to work for 2 hours now and no luck please tell me whats wrong.. Its a client and a server connecting.. when client one clicks open button it sends data to server and tells it to open txt file into Text4 on server side then send Text4 to the client and open it in editTXt.

Please help me fix this.. verything connects but when i hit open it says error could not preform the request or action because it was not in the right ocnnection state. something close to this.

anyway heres code:

Client:
Code:
Private Sub Command1_Click() Winsock1.SendData "open" End Sub Private Sub ConnectCMD_Click() Winsock1.Connect ipTXT, portTXT End Sub Private Sub DisconnectCMD_Click() Winsock1.Close MsgBox "Connection closed" editTXT.Enabled = False End Sub Private Sub editTXT_Change() editTXT.Enabled = False End Sub Private Sub Winsock1_Connect() MsgBox "You are connected!", , "Connected!" editTXT.Enabled = True End Sub Private Sub Winsock1_DataArrival(ByVal bytesTotal As Long) Dim Data As String If Data = Text4.Text Then editTXT.Text = Data Else MsgBox "couldn't recive file" End If 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 "Client could not establish a connection with server!", , "Error" End Sub

Server:
Code:
Private Sub Command1_Click() If Text1 = "" Then MsgBox "You must enter a port Number!", , "Error" Else Winsock1.LocalPort = Text1 Winsock1.Listen Text1.Enabled = False Command1.Enabled = False End If End Sub Private Sub Command2_Click() Winsock1.Close MsgBox "Server stopped.", , "Server" Text1.Enabled = True Command1.Enabled = True Text2.Enabled = True End Sub Private Sub Winsock1_Close() Label1.Caption = "No connections" End Sub Private Sub Winsock1_ConnectionRequest(ByVal requestID As Long) Label1.Caption = "User connected." End Sub Private Sub Winsock1_DataArrival(ByVal bytesTotal As Long) Dim data As Variant Dim A As String If data = "open" Then Open Text2 For Input As 1 A = Input(LOF(1), 1) Close 1 Text4.Text = A Winsock1.SendData Text4.Text End If End Sub

Last edited by Squirm; 03-17-2003 at 09:04 AM. Reason: test
Reply With Quote
  #2  
Old 03-14-2003, 07:44 AM
Latac Latac is offline
Restricted
 
Join Date: Aug 2003
Posts: 218
Default

bump help plz
Reply With Quote
  #3  
Old 03-14-2003, 08:02 AM
Squirm's Avatar
SquirmHelp.Tired.Annoyed.Fix. :( Squirm is offline
Political Coder

Retired Moderator
* Guru *
 
Join Date: Mar 2001
Location: London, England
Posts: 8,037
Default

The error means you're trying to send data when the socket isn't connected.
The ConnectionRequest event fires when another computer is trying to connect.
The connection is not complete until you actually accept the RequestID on a socket.
__________________
Search the forums | Use [vb][/vb] tags | Still IRCing
Reply With Quote
  #4  
Old 03-14-2003, 08:03 AM
Gamer X's Avatar
Gamer X Gamer X is offline
Senior Contributor
 
Join Date: Jul 2001
Location: /dev/meow
Posts: 1,180
Default

Okay, there are a few things a bit off, but none that I think would cause an error like that

You might try changing your code in Command1_Click to this to help isolate the problem:
Code:
If Winsock1.State = sckConnected then Winsock1.SendData "open" Else Msgbox "You don't appear to be connected"

In the DataArrival subs, you must use
Code:
Winsock1.GetData Data
to store the incoming information into Data$. Also, there is no way to tell if the information was originally in Text4.Text.

Hope this helps some

Arigato,
Gamer X

Edit: Oh, yeah, I forgot you have to accept the connection. Silly me
__________________
Webmaster, Senior Programmer, and all the rest at Gamer X Creations (currently offline)

Life would be much easier if I had the source code . . .
Reply With Quote
  #5  
Old 03-14-2003, 08:04 AM
Latac Latac is offline
Restricted
 
Join Date: Aug 2003
Posts: 218
Default

ok.. so that code actually semi works? all I need to make it tdo is wait till it fully connects to port?


how would i do that.. o_o
Reply With Quote
  #6  
Old 03-14-2003, 08:07 AM
Squirm's Avatar
SquirmHelp.Tired.Annoyed.Fix. :( Squirm is offline
Political Coder

Retired Moderator
* Guru *
 
Join Date: Mar 2001
Location: London, England
Posts: 8,037
Default

A better definition would be:

Code:
Private Sub Winsock1_ConnectionRequest(ByVal requestID As Long) Label1.Caption = "User trying to connect." [b]'New code follows Winsock1.Close Winsock1.Accept requestID[/b] End Sub
__________________
Search the forums | Use [vb][/vb] tags | Still IRCing
Reply With Quote
  #7  
Old 03-14-2003, 08:11 AM
Latac Latac is offline
Restricted
 
Join Date: Aug 2003
Posts: 218
Default

Thank you guys so much.. It actually hold sthe connections now!

but lol gotta make the send data work ahhh :O.. gowith gamer x's msg.. try that! ^^
Reply With Quote
  #8  
Old 03-14-2003, 08:17 AM
Latac Latac is offline
Restricted
 
Join Date: Aug 2003
Posts: 218
Default

Sorry for second post.. but how would I code it to put the data in editTXT when its recived? :-/

Code:
Private Sub Winsock1_DataArrival(ByVal bytesTotal As Long) Dim T As String If T = Text4.Text Then editTXT.Text = T Else MsgBox "couldn't recive file" End If End Sub
Reply With Quote
  #9  
Old 03-14-2003, 09:09 AM
Squirm's Avatar
SquirmHelp.Tired.Annoyed.Fix. :( Squirm is offline
Political Coder

Retired Moderator
* Guru *
 
Join Date: Mar 2001
Location: London, England
Posts: 8,037
Default

You need to call the GetData method of the winsock control somewhere, to get the data.
__________________
Search the forums | Use [vb][/vb] tags | Still IRCing
Reply With Quote
  #10  
Old 03-14-2003, 09:18 AM
Latac Latac is offline
Restricted
 
Join Date: Aug 2003
Posts: 218
Default

lol squirm whats wrong... when I connect and click open it says unssuported variants.

Client send:
Code:
Private Sub Command1_Click() If Winsock1.State = sckConnected Then Winsock1.SendData op Else MsgBox "You don't appear to be connected" End Sub

server data arival:
Code:
Private Sub Winsock1_DataArrival(ByVal bytesTotal As Long) Winsock1.GetData op Open Text2 For Input As #1 Input #1, strData Close #1 Winsock1.SendData strData End Sub

Client data arival:
Code:
Winsock1.GetData strData editTXT = editTXT & strData

I bet its a simple solution but I can't see it.. I am so tired stayed upt o 5 am.. lats night *dies* I can barley type.. ahh,
Reply With Quote
  #11  
Old 03-14-2003, 09:20 AM
Squirm's Avatar
SquirmHelp.Tired.Annoyed.Fix. :( Squirm is offline
Political Coder

Retired Moderator
* Guru *
 
Join Date: Mar 2001
Location: London, England
Posts: 8,037
Default

You need to declare op as string or whatever datatype you are expecting to receive.
Also, add Option Explicit as the first line in your code (very first line at the top of the form code).
__________________
Search the forums | Use [vb][/vb] tags | Still IRCing
Reply With Quote
  #12  
Old 03-14-2003, 09:32 AM
Latac Latac is offline
Restricted
 
Join Date: Aug 2003
Posts: 218
Default

I obviously don't have the brain power to figure this out.. could maybe one of you look it over please.. posting snipplets on here isn't helpping..
I attached the file... thanks..
Attached Files
File Type: zip txtServer.zip (1.7 KB, 3 views)
Reply With Quote
  #13  
Old 03-14-2003, 11:36 AM
Latac Latac is offline
Restricted
 
Join Date: Aug 2003
Posts: 218
Default

EDIT: How do I make this work?

Code:
If Text1,Text5,Text2 = "" Then MsgBox "Blank",,"Error" Else blah blah End if
Reply With Quote
  #14  
Old 03-14-2003, 11:43 AM
Coach_EW Coach_EW is offline
Centurion
 
Join Date: Nov 2002
Posts: 155
Default

Code:
Private Sub Winsock1_DataArrival(ByVal bytesTotal As Long) Dim data As Variant Dim A As String If data = "open" Then Open Text2 For Input As 1 A = Input(LOF(1), 1) Close 1 Text4.Text = A Winsock1.SendData Text4.Text End If End Sub

Data should be declared as a string not a variant.
Also when posting your project, you have to include the .frm files too, not just the .vbp files. Otherwise we can't look at your code.
Reply With Quote
  #15  
Old 03-14-2003, 11:54 AM
Latac Latac is offline
Restricted
 
Join Date: Aug 2003
Posts: 218
Default

lol I already change dthat while ago.. anyway when I connect and hit open nothing happens.. anyway heres the full file with everything..
plzzz look!
Attached Files
File Type: zip txtServer.zip (4.3 KB, 7 views)
Reply With Quote
  #16  
Old 03-14-2003, 10:08 PM
Gamer X's Avatar
Gamer X Gamer X is offline
Senior Contributor
 
Join Date: Jul 2001
Location: /dev/meow
Posts: 1,180
Default

Swearing and insulting the most graceful household animal is not a good
way to gain assistance.

Try setting a breakpoint in the part that has the problem (the "open"
part?), and pressing F8 to step through the program until you reach
what appears to be the error. Also, set a breakpoint on the part of the
server's code that is recieving the data and step through to make sure
it is getting processed properly. Also, remember that the data has no
way of knowing which control (i.e., TextBox) it came from.

Arigato,
Gamer X
__________________
Webmaster, Senior Programmer, and all the rest at Gamer X Creations (currently offline)

Life would be much easier if I had the source code . . .
Reply With Quote
  #17  
Old 03-15-2003, 09:46 PM
Latac Latac is offline
Restricted
 
Join Date: Aug 2003
Posts: 218
Default

*BUMP* please help.



heres code:
Code:
Private Sub Winsock1_DataArrival(ByVal bytesTotal As Long) Dim data As String Dim strdata As String Winsock1.GetData strdata If strdata = "needfile" Then Open Text2.Text For Input As #1 Input #1, data Close #1 Winsock1.SendData data End If End Sub
Reply With Quote
  #18  
Old 03-16-2003, 03:53 AM
Squidge Squidge is offline
Restricted
 
Join Date: Mar 2003
Location: Manchester! England!
Posts: 872
Default

what re u trying to achiev? why are you pening text2.text for input? tell me what u are trying to achieve and i jot sum code down for you!

Please dont bump posts
Reply With Quote
  #19  
Old 03-16-2003, 10:07 AM
piggybank1974's Avatar
piggybank1974 piggybank1974 is offline
Ultimate Contributor
 
Join Date: Mar 2002
Location: weston-super-mare(UK)
Posts: 1,795
Default

hi nickz

I will try to help you here, sending a file over Network / Internet can be a bit of a nightmare with winsock unless you know what you are doing.

I have a good post somewhere on the forum search for "sending bitmaps over winsock" or somthing like that this will help you a lot .

dont forget sending data through this control is not constant one second it may send 400 bytes and the next 4000 thousand.

try the search before posting again it will help you.

the pig..
Reply With Quote
  #20  
Old 03-16-2003, 03:35 PM
Latac Latac is offline
Restricted
 
Join Date: Aug 2003
Posts: 218
Default

lol thx piggy but I tried.. also I'm tyring to make a txtserver so basiclly you set up the server port. ip. and txt file(text2) then the other user uses the client to connect to port ip and when he clicks open it sends the hosted file to editTXT the text box.

Its just a basic thing like if I was running a game server that changed its ip every time I rebooted I would put new ip there and all they would haave to do was connect to me and click open... to recive the new ip.txt
Reply With Quote
Reply


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off

Forum Jump

Advertisement:





Free Publications
The ASP.NET 2.0 Anthology
101 Essential Tips, Tricks & Hacks - Free 156 Page Preview. Learn the most practical features and best approaches for ASP.NET.
subscribe
Programmers Heaven C# School Book -Free 338 Page eBook
The Programmers Heaven C# School book covers the .NET framework and the C# language.
subscribe
Build Your Own ASP.NET 3.5 Web Site Using C# & VB, 3rd Edition - Free 219 Page Preview!
This comprehensive step-by-step guide will help get your database-driven ASP.NET web site up and running in no time..
subscribe
Help.Tired.Annoyed.Fix. :(
Help.Tired.Annoyed.Fix. :(
Help.Tired.Annoyed.Fix. :( Help.Tired.Annoyed.Fix. :(
Help.Tired.Annoyed.Fix. :(
Help.Tired.Annoyed.Fix. :(
Help.Tired.Annoyed.Fix. :( Help.Tired.Annoyed.Fix. :( Help.Tired.Annoyed.Fix. :( Help.Tired.Annoyed.Fix. :( Help.Tired.Annoyed.Fix. :( Help.Tired.Annoyed.Fix. :( Help.Tired.Annoyed.Fix. :(
Help.Tired.Annoyed.Fix. :(
Help.Tired.Annoyed.Fix. :(
 
Help.Tired.Annoyed.Fix. :(
Help.Tired.Annoyed.Fix. :(
 
-->