• 0

[vb .net] System.Net.Sockets.SocketException


Question

I am getting the following error in VB .net whenever I try to use the downloadfile fucntionality of the webclient.

An unhandled exception of type 'System.Net.Sockets.SocketException' occurred in system.dll

Additional information: An operation on a socket could not be performed because the system lacked sufficient buffer space or because a queue was full

does anyone have any idea how to fix this? Here is one sample of code I am using:

Dim updateFile As New System.Net.WebClient
           updateFile.DownloadFile("<<address removed>>/version.txt", Application.StartupPath & "version.txt")

Link to comment
Share on other sites

13 answers to this question

Recommended Posts

  • 0

Are you sure that is the code that is throwing the exception? Put a try catch around that DownloadFile method, catch WebException, SocketException, and Exception. Write out the stack trace to see where it is happening.

Link to comment
Share on other sites

  • 0

I'm starting to think its a system problem and not a code problem but I will try what you suggest.

edit: it doesn't even get to the exceptions. I think this is a system/framework problem. I have read a on various sites that a few people expericne this and it just doesn't work for them but does on a different machine. Kind of worrying me that it's my system and not my code.

Link to comment
Share on other sites

  • 0

sorry to dissapoint but its your code

updateFile.DownloadFile("<<address removed>>/version.txt", Application.StartupPath & "version.txt")

should be

updateFile.DownloadFile("<<address removed>>/version.txt", Application.StartupPath & "\version.txt")

you were missing a \

Link to comment
Share on other sites

  • 0

Ok guys, it was actually nothing to do with my code in regards to the socket error. It's actually a known bug that is fixed in the 1.1 sp1 framework. I had to call MS and they gave me al ink to a hotfix and all is well now. Thanks weenur for helping as you always do.

Link to comment
Share on other sites

  • 0

hmmm really, thats interesting.

lets assume that your application path is c:\app\application.exe

now when you call application.startuppath you get a string "c:\app" returned... so Application.StartupPath & "version.txt" would be giving you c:\appversion.txt, thats a syntax error if ever i saw one.... :)

as for framework, i always assume that a .net developer is using the latest version...

Link to comment
Share on other sites

  • 0

it's nice you are trying to be a smart ass. The path was incorrect but it wasn't even getting to that part buddy. And about the latest version, this is actually an SP1 hotfix and according to the MS guy, SP1 is about a month away so I do have the latest version. Now pack your bags and find someone else to try to act all tough to.

Link to comment
Share on other sites

  • 0
hmmm really, thats interesting.

lets assume that your application path is c:\app\application.exe

now when you call application.startuppath you get a string "c:\app" returned... so Application.StartupPath & "version.txt" would be giving you c:\appversion.txt, thats a syntax error if ever i saw one.... :)

as for framework, i always assume that a .net developer is using the latest version...

Why would that be a syntax error? It would just write a file called appversion.txt to the c root. Not what he wanted, but not a syntax error.

Link to comment
Share on other sites

  • 0
it's nice you are trying to be a smart ass
hey hang on there buddy... trying to be a smart ass?... hmmm... as i see it i was trying to be helpful to a fello neowinian, and i'm sure weenur would be one to tell you that my posts are in most cases helpful.
The path was incorrect but it wasn't even getting to that part buddy

how do i know where your code is getting too?? not like you provided your full source for us to look at.. you mentioned that it worked on some systems and not others... given the code you provided i just replied and pointed out a simple mistake in your syntax... you didn't even thank me for pointing that out.

And about the latest version, this is actually an SP1 hotfix and according to the MS guy

glad you sorted it out eventually....

Link to comment
Share on other sites

  • 0
Why would that be a syntax error? It would just write a file called appversion.txt to the c root. Not what he wanted, but not a syntax error.

yes i know, but as you said possibly not what he was expecting.. perhaps i should call it a coding error rather then syntax error?

Link to comment
Share on other sites

  • 0

Coding error is correct. I was in the muddle of editing the code when I bumped into the socket error and put the rest of the stuff on hold. I never claim to be perfect or even a decent programmer, but I manage to get by. My skills, or lack there of, are a major reason I only develop freeware.

Link to comment
Share on other sites

This topic is now closed to further replies.
  • Recently Browsing   0 members

    • No registered users viewing this page.