forum.vdsworld.com Forum Index forum.vdsworld.com
Visit VDSWORLD.com
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 


Help with this code (BINFILE + vdsipp.dll)

 
Post new topic   Reply to topic    forum.vdsworld.com Forum Index -> General Help
View previous topic :: View next topic  
Author Message
DW
Contributor
Contributor


Joined: 21 Mar 2003
Posts: 175
Location: UK

PostPosted: Fri Jan 09, 2004 10:47 am    Post subject: Help with this code (BINFILE + vdsipp.dll) Reply with quote

Ok, I am try a simple send file program I can use to send files over the net to a server.

I am just playing with how it works so the code looks bad.

My client code is this;

Code:

:Main
external @path(%0)vdsipp.dll
Title test client
  DIALOG CREATE,New Dialog,-1,0,365,329
  DIALOG ADD,LIST,LIST1,8,12,332,272
  DIALOG ADD,BUTTON,BUTTON1,292,30,292,24,Send
  DIALOG SHOW
:Evloop
  wait event
  goto @event()
:BUTTON1BUTTON
 
 
  %%InFile = c:\test.exe
  %%Pos = 0
  %%Bytes = 200
  INTERNET TCP,CREATE,1
  INTERNET TCP,THREADS,1,on
  INTERNET TCP,CONNECT,1,localhost,9000
 
  BINFILE OPEN,1,%%InFile,READ
  REPEAT
    BINFILE SEEK,1,%%Pos 
    %%Read = @BINFILE(READ,1,BINARY,%%Bytes)
   INTERNET TCP,SEND,1,%%Read
   list add,list1,sent %%Bytes from pos %%pos
    %%Pos = @FADD(%%Pos,%%Bytes)
  UNTIL @BINFILE(EOF,1)
  BINFILE CLOSE,1
 
  INTERNET TCP,DISCONNECT,1
  INTERNET TCP,DESTROY,1
  goto evloop
 
  :TCP1ONCONNECT
  list add,list1,connected
 goto evloop
:TCP1ONDISCONNECT
list add,list1,disconnected
 goto evloop
:TCP1ONMESSAGE
list add,list1,message
 goto evloop
:TCP1ONSENDDONE
list add,list1,send done
 goto evloop
:Close
  exit


Server code is;

Code:
:Main
external @path(%0)vdsipp.dll
Title test sever
  DIALOG CREATE,svr,-1,0,365,329
  DIALOG ADD,LIST,LIST1,8,12,332,272
  DIALOG ADD,BUTTON,BUTTON1,292,30,292,24,Send
  DIALOG SHOW
:Evloop
  wait event
  goto @event()
:BUTTON1BUTTON
 
  %%outfile = c:\server\test.exe
  %%Pos = 0
REM How many bytes to read/write at a time.
  %%Bytes = 200
  INTERNET TCP-SERVER,CREATE,1
  INTERNET TCP-SERVER,ACTIVATE,1,9000
      goto evloop
 
  :TCP-sever1ONCONNECT
  list add,list1,connected
   
  BINFILE OPEN,2,%%OutFile,CREATE
  REPEAT
    BINFILE SEEK,2,%%Pos 
    %%Read = @INTERNET(TCP-SERVER,MESSAGE,1)
   list add,list1,getting file.
    BINFILE WRITE,2,BINARY,%%Read
    %%Pos = @FADD(%%Pos,%%Bytes)
  UNTIL @equal(@INTERNET(TCP-SERVER,USERCOUNT,1),0)
  BINFILE CLOSE,2

 goto evloop
:TCP-server1ONDISCONNECT
list add,list1,disconnected
 goto evloop
:TCP-server1ONMESSAGE
list add,list1,message
 goto evloop
:Close
  exit


When I run them both and click send on the svr and client i get errors from the client saying run time error 27 @ line 25
and the server says error 12 @ line 9

I though it was something to do with the size of what was set but lowering the bytes changed nothing.
Also, test.exe is on drive c: and the folder server does exist.
Back to top
View user's profile Send private message
Vic D'Elfant
Past Contributor
Past Contributor


Joined: 26 Jun 2002
Posts: 673
Location: The Netherlands

PostPosted: Fri Jan 09, 2004 10:51 am    Post subject: Reply with quote

I've changed your post... it now uses the [code] tag to increase readabilty and your script is now downloadable Wink

Best regards,
Vic

_________________
phpBB Development Team
Back to top
View user's profile Send private message Visit poster's website
Vic D'Elfant
Past Contributor
Past Contributor


Joined: 26 Jun 2002
Posts: 673
Location: The Netherlands

PostPosted: Fri Jan 09, 2004 11:04 am    Post subject: Reply with quote

BTW: Have a look at the following two scripts. They're actually the same as yours Wink
You can read more about it here

File server
Code:

option decimalsep,.
  %%Port = 6321
  rem Adjust to server port
  %%SplitSize = 256
  external vdsinet.dll,
  rem Don't forget to insert your registration code -- it's freeware by now; Januari 9, 2004
  external vdsinout.dll
  dialog create,Dummy,0,0,0,0
  net socket,addr,%­dr
  net socket,port,%%Port
  net socket,server
  wait event
  %E = @event()
  if @not(@equal(%E,ACCEPT))
    goto checkerror
  end
  rem *** THE %%FILE IS THE FILE TO SAVE
  %%Id = @net(socket,senderid)
  %%File = @filedlg("All files (*.*)|*.*",Select destination file,,SAVE)
  if @not(@ok())
    goto close
  end
  io toparm,LENGTH
  io reduce,OFF
  io exclusive,OFF
  %%Pos = @diff(1,%%SplitSize)
  net socket,sendid,%%Id,START
  repeat
    %%Pos = @sum(%%Pos,%%SplitSize)
    rem *** I GUESS YOU NEED THE MCI PLAY COMMANDS UNDER A TIMER EVENT
:BUFFERING
    wait event,0.1
    %E = @event()
    if @equal(%E,NETWORK)
      %A = @io(writb,@net(socket,data),%%File,%%Pos)
      rem *** MAYBE YOU SHOULD TRY TO USE THE MCI COMMANDS HERE ? (TO PLAY PART OF THE FILE SENT

      net socket,sendid,%%Id,OK
    end
  until @not(@equal(%E,NETWORK))
  rem *** RECEIVING IS DONE AT THIS POINT
:checkerror
  if @equal(%E,ERROR)
    info Network error: @net(socket,error)
  end
:close
  exit

:TIMER
  rem *** HERE GOES THE MCI COMMANDS

  goto BUFFERING


File client:
Code:

%­dr = "127.0.0.1"
  rem Adjust to server IP address
  %%Port = 6321
  rem Adjust to server port
  %%SplitSize = 256
  external vdsinet.dll,
  rem Don't forget to insert your registration code -- it's freeware by now; Januari 9, 2004
  external vdsinout.dll
  dialog create,Dummy,0,0,0,0
  net socket,addr,%­dr
  net socket,port,%%Port
  net socket,client
  wait event
  %E = @event()
  if @not(@equal(%E,CONNECT))
    goto checkerror
  end
  rem *** %%FILE IS THE FILE TO SEND
  %%File = @filedlg("All files (*.*)|*.*",Select input file)
  if @not(@ok())
    goto close
  end
  io toparm,LENGTH
  io reduce,OFF
  io exclusive,OFF
  %%Size = @file(%%File,Z)
  %%Pos = @diff(1,%%SplitSize)
  wait event
  %E = @event()
  if @not(@equal(%E,NETWORK))
    goto checkerror
  end
  %A = @net(socket,data)
  repeat
    %%Pos = @sum(%%Pos,%%SplitSize)
    net socket,sendserver,@io(readb,%%File,%%Pos,%%SplitSize)
    wait event
    %E = @event()
    %A = @net(socket,data)
  until @greater(@pred(@sum(%%Pos,%%SplitSize)),%%Size)@not(@equal(%E,NETWORK))
:checkerror
  if @equal(%E,ERROR)
    info Network error: @net(socket,error)
  end
:close
  exit


Best regards Smile
Vic

_________________
phpBB Development Team
Back to top
View user's profile Send private message Visit poster's website
DW
Contributor
Contributor


Joined: 21 Mar 2003
Posts: 175
Location: UK

PostPosted: Fri Jan 09, 2004 1:59 pm    Post subject: Reply with quote

Thank you and Thank you, I shall download and read in to these scripts.
Back to top
View user's profile Send private message
PGWARE
Web Host


Joined: 29 Dec 2001
Posts: 1565

PostPosted: Fri Jan 09, 2004 3:43 pm    Post subject: Reply with quote

DW if you are using VDS 5 make sure you are using the latest version of VDSIPP. Older versions of vdsipp simply will not work and throw up similar errors.


Also note in your server code you had:
:TCP-sever1ONCONNECT

This obviously is missing an 'R' in the word server. This could be causing a problem as the server code will crash due to missing event. The client may also cause an error as it never connects to the server correctly.

Also since the onconnect in the client does not happen since the server is crashing, you then try to send data which more then likely is causing the error within the client.

Finally you're using the code incorrectly, in that you are attempting to CONNECT with the server, but then you immediately proceed with code. This will cause the the client ONCONNECT event to possibly be blocked if another event occurs. It also does not let you check to see if a valid connection ever happend.

You should immediately after trying a CONNECT command go to the evloop and wait to see if any connnections occurred - you will get an ONCONNECT event where you can then proceed with more code. This way you know a connection has been made.
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic    forum.vdsworld.com Forum Index -> General Help All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
You can attach files in this forum
You can download files in this forum

Twitter@vdsworld       RSS

Powered by phpBB © 2001, 2005 phpBB Group