Important alert: (current site time 7/15/2013 8:08:17 AM EDT)
 

winzip icon

A Winsock File Transfer example for VB.NET (and it works! :) Clocked at 1Meg/second over 10mBit LAN

Email
Submitted on: 3/10/2002 6:33:48 AM
By: Jon Barker  
Level: Intermediate
User Rating: By 10 Users
Compatibility: VB.NET
Views: 75920
(About the author)
 
     This code (the first of its kind in the VB.NET section of PSC) will allow you to quickly and easily send a file over dialup, LAN or BroadBand. Works fine, and all the programs that i tested it on (from 20k to 200Meg worked fine after the transfer!) If you have a brief knowlage of file manipulation, this should be pretty simple to understand.

 
winzip iconDownload code

Note: Due to the size or complexity of this submission, the author has submitted it as a .zip file to shorten your download time. Afterdownloading it, you will need a program like Winzip to decompress it.Virus note:All files are scanned once-a-day by Planet Source Code for viruses, but new viruses come out every day, so no prevention program can catch 100% of them. For your own safety, please:
  1. Re-scan downloaded files using your personal virus checker before using it.
  2. NEVER, EVER run compiled files (.exe's, .ocx's, .dll's etc.)--only run source code.

If you don't have a virus scanner, you can get one at many places on the net including:McAfee.com

 
Terms of Agreement:   
By using this code, you agree to the following terms...   
  1. You may use this code in your own programs (and may compile it into a program and distribute it in compiled format for languages that allow it) freely and with no charge.
  2. You MAY NOT redistribute this code (for example to a web site) without written permission from the original author. Failure to do so is a violation of copyright laws.   
  3. You may link to this code from another website, but ONLY if it is not wrapped in a frame. 
  4. You will abide by any additional copyright restrictions which the author may have placed in the code or code's description.


Other 14 submission(s) by this author

 


Report Bad Submission
Use this form to tell us if this entry should be deleted (i.e contains no code, is a virus, etc.).
This submission should be removed because:

Your Vote

What do you think of this code (in the Intermediate category)?
(The code with your highest vote will win this month's coding contest!)
Excellent  Good  Average  Below Average  Poor (See voting log ...)
 

Other User Comments

6/19/2002 3:21:14 AMNiels Krogh

Hi there,

I'm getting an error : 'File Transfer Send.vb(173): 'State' is a type in 'AxMSWinsockLib.AxWinsock' and cannot be used as an expression.'

It occurs in 'wsSend_ConnectionRequest subroutine where you compare the 'wsSend.state'

If wsSend.State <> MSWinsockLib.StateConstants.sckClosed Then
If wsSend.State = MSWinsockLib.StateConstants.sckConnected Then

Any suggestions ?

Regards,
Niels K.

(If this comment was disrespectful, please report it.)

 
6/19/2002 6:26:22 AMTom Garratt

Nice code, this worked well (to localhost anyway)

I figured out a solution to the "State" problem, just change wsSend.CtlState for wsSend.CtlState.

Keep up the good work, Tom
(If this comment was disrespectful, please report it.)

 
6/19/2002 6:27:30 AMTom Garratt

Sorry I meant change wsSend.State to wsSend.CtlState, I'm pretty sure u got that already.
(If this comment was disrespectful, please report it.)

 
7/22/2002 11:57:03 AMtammy

Does anyone know where to find a .net sample for multiple connections?
(If this comment was disrespectful, please report it.)

 
7/2/2003 5:41:52 AM

This program can not connect to remote PC, does any one know the way to connect it or the port to use
(If this comment was disrespectful, please report it.)

 
9/7/2003 12:28:14 AMDanny J

omg winsock in .NET??? How in the world???
(If this comment was disrespectful, please report it.)

 
11/12/2003 4:32:43 AM

send the code which will transfer all types of file such as *.jpg, *.bmp ,MP3 etc. although it is fine.
(If this comment was disrespectful, please report it.)

 
12/8/2003 6:26:21 PM

wsSend and wsReceive arent declared...
(If this comment was disrespectful, please report it.)

 
1/31/2004 10:41:35 PMEJ Thiele

hi, yah, hummm, When u want to use file transfer use System.net.sockets.TCPClient and TCPLisner.
Then use the GetStream.Write and GetStream.Read.

Evern better, attack the Crypto Stream to it and use Triple DES. Let .net handle the winsock, it wount be there for long, indigo is comming.
(If this comment was disrespectful, please report it.)

 
3/25/2004 10:17:59 PMKah Wee

i got the error of:
You do not have the license to use the ActiveX
(If this comment was disrespectful, please report it.)

 
4/6/2004 11:32:58 PM

I'm getting the same error about the ActiveX license. I would appreciate any help.
(If this comment was disrespectful, please report it.)

 
4/22/2004 12:52:04 PM

wne i run the code the and that is and error. 'AxMSWinsockLib.AxWinsock' is not define.'AxMSWinsockLib.DMSWinsockControlEvents_DataArrivalEvent' is not defined. so how i going to slove the problem


(If this comment was disrespectful, please report it.)

 
8/20/2004 3:48:46 PMZolt

Get the same ActiveX Lisence (from VS.NET 2003) Can someone help?

the cleaner?!?
(If this comment was disrespectful, please report it.)

 
9/16/2004 2:57:56 AM

Hi, may I know how to send just plain text? I tried but it unable to receive. Thanks
(If this comment was disrespectful, please report it.)

 
11/18/2004 11:26:21 PM

uh! i can't find axinterop.mswinsocklib.dll. can you help me?
please, send for me;
dongkb2001@yahoo.com
(If this comment was disrespectful, please report it.)

 
2/25/2005 1:56:15 PM

The ActiveX license error is a known issue with Visual Studio.Net. Microsoft has described the bug and provides a work around. Its located at http://support.microsoft.com/default.aspx?scid=kb;en-us;318597

(If this comment was disrespectful, please report it.)

 
8/23/2005 1:12:08 PMMike Koenig

Nice program. Thanks for the source code.

:)
(If this comment was disrespectful, please report it.)

 
9/16/2005 9:07:39 AMsarith

For all those who waited for a loooong time beacause of that winsock file? Well just install VB 6.0 with Activex. And vs.net will automatically install the file to it self.!
(If this comment was disrespectful, please report it.)

 
9/16/2005 9:21:35 AMsarith

How in the worl can i use this through a dial up internet?
(If this comment was disrespectful, please report it.)

 
2/25/2006 4:48:10 PMRimsey

Sorry but using the winsock control through interop is useless. This app would have been good if it had used sockets insteack of an ocx that need registering.
(If this comment was disrespectful, please report it.)

 
4/4/2006 2:36:03 PMarchana

wne i run the code the and that is and error. 'AxMSWinsockLib.AxWinsock' is not define.'AxMSWinsockLib.DMSWinsockControlEvents_DataArrivalEvent' is not defined. so how i going to slove the problem

Type 'AxMSWinsockLib.AxWinsock' is not defined.

(If this comment was disrespectful, please report it.)

 
1/24/2007 1:02:48 PMef_zero

using mswinsck.ocx in .net is a rather primitive way of transfering data dont ya think? none the less nice little example on simple way of reading data from filesystem.. nice work
(If this comment was disrespectful, please report it.)

 
4/27/2007 12:09:42 PM

wne i run the code the and that is and error. 'AxMSWinsockLib.AxWinsock' is not define.'AxMSWinsockLib.DMSWinsockControlEvents_DataArrivalEvent' is not defined. so how i going to slove the problem

Type 'AxMSWinsockLib.AxWinsock' is not defined.

You should fownload mswinsck.ocx and copy it to windows\system32\ directory. Then add it to your toolbox.
(If this comment was disrespectful, please report it.)

 
3/2/2009 2:35:21 PMKenny28

streams = better than winsock
(If this comment was disrespectful, please report it.)

 
10/10/2009 3:41:40 PMROcket

OE broer En visual basic .net se puede usar sockets como en vb6?? me refiero como un object y no creando clases, propiedades y todo eso.... Como t dije trate de bajarme el winsock version 6 y cargarlo no nada... como has hecho...
(If this comment was disrespectful, please report it.)

 

Add Your Feedback
Your feedback will be posted below and an email sent to the author. Please remember that the author was kind enough to share this with you, so any criticisms must be stated politely, or they will be deleted. (For feedback not related to this particular code, please click here instead.)
 

To post feedback, first please login.