.net - Sending Jpegs By Tcp Socket Sometimes Incomplete?
Apr 17, 2010
I've been working on a project for months now (vb 2008 express). There is one final which I can't solve.I need to send images to a client from a 'server'(listener). The code below works most of the time but sometimes the image is incomplete. I believe this might be something to do with the tcp packet sizes varying, maybe limited by how busy it is out there on the net. I have seen examples of code that splits the image into chunks and sends them out, but I can't get them to work maybe because I'm using a different vb version. The pictures to be sent are small 20k max.
Any working code examples would be wonderful. I have been experimenting and failing with this final hurdle for weeks.
Private Sub Button1_Click(ByVal sender As System.Object, _ ByVal e As System.EventArgs) Handles Button2.Click readData = "Conected to Chat Server ..." msg()
Given the following information Public Enum Request As Byte None = 0 Identity = 1 License = 2 End Enum Protected mType As Communication.Request mType = Communication.Request.Identity Debug.Print (BitConverter.GetBytes(mType).Length.tostring) 2
Why does bitconverter report that mType is a length of 2. I would have thought that passing a Byte into BitConverter.GetBytes would just return the Byte. I mean it's no big deal because it's only sending a very small block of data across a TCP Socket, but I'm just intrigued why it thinks it's 2 bytes.
I'm writing a GUI-based app in VB.net that talks to a LambdaMOO server via telnet, sends commands to display the object hierarchy, then parses the output and creates a visual representation of the object hierarchy.So my question is: is there some kind of "telnet client" class for .NET to simplify the sending and receiving of data, or do I have to write my own using the socket API?
i am using itextsharp and creating a PDF with images. currently the images i am using in the application are on my desktop, but i will need to make an installation file that will put the images in a specified directory on the users computer and be able to call them from the specific directory.how do i include pictures with my build?how do i reference the pictures? currently i am using:
Dim jpeg3 As Image = Image.GetInstance(Environment.GetFolderPath(Environment.SpecialFolder.Desktop) & "2.jpg")
I wrote a Socket Client which will send the Socket Server some data and get some response from Server. This process will be running once in every 2 seconds.
Now what I need to know is How we can identify the connection lost between Server and Client?
I need this to be implemented in the Client side. If there is no connection then Client should automatically close the connection. Once the connection with the server is available in the next attempt it should connect automatically.
As part of test automation framework building, I need to record the activities done by the user in a video. Since I could not find a way to record a video directly in vb, I opted to capture a sequence of screen shots (print screens) and then convert it to a streaming video.
when i am building the installation file i need to be including some jpegs and i need them to be saved to a specific location how do i include jpegs in the installation? how do i have them be extracted to specific directories?
I'm saving a bitmap as a jpeg using: savedImage.Save(fileName, System.Drawing.Imaging.ImageFormat.Jpeg) which is resulting in a JPEG with a 96dpi x 96dpi resolution and a 24-bit color depth. Is there a way in VB .NET 1.1 to change this to say a 72 x 72 dpi resolution and a 16-bit color depth?
I am creating some Jpegs on the fly using the copy method within Office products. Effectively I am taking a snapshot of some tables in Excel. I know how to copy the data. I now want to store the copied data into files in a temp directory. How do I take the information which is now on the Clipboard and paste it to a file which can be saved in a temp drive?
I've almost finished my multimedia project. On the photobrowser (which constructs thumbnails of every photo in a folder and draws them onto a bitmap which I then make persistent and from which the user can select a thumbnail and the image is shown in full on a new form). You can print the bitmap consisting of 100s of thumbnails or the full image associated with a thumbnail. The onloy thing missing is getting all the Exif info - which is proving more difficult than I expected despite the propetyitems in vb.net. Yes, I have set the encoding to UTF8 etc.
I'm trying to connect and query a .dbf dBase table. I'm fairly certain I've got the connection string formatted properly, because I am no longer receiving errors that I can't locate the table.I've tried everything I can think of, and nothing seems to work to make a valid query. I've tried all sorts of syntax changes around the table name (which is just 'buildings'...nothing fancy). The error is a syntax error with an incomplete query on the executereader line.
I use the webbrowser control in my program but when after navigate to a site. I try to get some element on the using the document of the webbrowser (like getelementbyid ... ) I notice that some element are missing. I know that elements are dynamically inserted into the page by some javascript. I searched method to get those element and I try to get them injecting a javascript to be executed in the page and return some element by window.external method (or just to try by alert) but even if this script are executed they just return the same result as the method on the document in the original code. Is there a way to access to this 'invisible' element in my program in some way just like I access them by pressing F12 in Internet Explorer?
Here is my code: private void button2_Click(object sender, EventArgs e) { //injecting and executing my javascript code HtmlElement head = webBrowser1.Document.GetElementsByTagName("head")[0]; HtmlElement scriptEl = webBrowser1.Document.CreateElement("script"); IHTMLScriptElement element = (IHTMLScriptElement)scriptEl.DomElement; [Code] ....
At the end of the execution both test and test2 have the same html were some element are missing.
Reading tags from a Geo-TIFF file works great on XP and Vista, but does not work on my new Windows 7 box using the exact same code and image. Several of the critical tags are missing. Here is my sample code:
Dim b As New Bitmap("C:myMap.tif") Dim list As String For Each p As PropertyItem In b.PropertyItems
Why would it be different? I'm compiling as 32bit (crashes if I try 64 bit); running as admin, have tried running the exe with various compatability modes set...no difference.
I am working on an app that requires searching the source code for a printer's web page for some information. I have used several methods to retrieve the source code (WebClient.DownloadString, HttpWebRequest.GetResponse) and in all cases recover only a portion of the web page. I can use View Source on the webpage and it is a 14K file, but using the VB functions I only get 5K of it. In these cases the data stops just prior to a <div class="tabBox"> tag containing data specific to the printer. I have also added code to pause the app, thinking that maybe it needed time for the page to complete before returning the code. Any ideas what I need to do to get the whole page?
I have a class that implements IXMLSerializable. With this interface comes WriteXML, ReadXML and GetSchema. I've noticed that the ReadXML implementation crashes beyond repair (i.e hangs indefinitely) while deserializing when the XML Data is incomplete.[code]
I have a class that implements IXMLSerializable. With this interface comes WriteXML, ReadXML and GetSchema. I've noticed that the ReadXML implementation crashes beyond repair (i.e hangs indefinitely) while deserializing when the XML Data is incomplete. For example, given the following XML
<SomeObject> <SomeValue>This is a string</SomeValue> <AnotherValue>This is another string</AnotherValue> </SomeObject>
Below is my code, but when i send the message thru client socket i receive Specified argument was out of the range of valid values. Parameter name: size
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
Dim serverStream As NetworkStream = clientSocket.GetStream() Dim outStream As Byte() = _ System.Text.Encoding.ASCII.GetBytes("0800822000000000000004000000000000000920092126012345001")
Form A accepts user input, closes and calls Form B when user wants to see results. Form B starts calculations automatically. Meanwhile, it partially displays and can disappear completely leaving an empty window. The calculations can take some time. It seems as if a form needs code to stop running and be awaiting user input before it finishes drawing itself. Is there a way to circumvent this? Aside from the aesthetics, I would like user to see progress reports posted to status bar and without needing to press another button (so removing automatic start). Form B has only a return button for input.
I have tried various places for Me.Show and addressing the form's controls from the modules it uses.
To object oriented programming and programming with visual basic .net (vb 2008 express). regarding storing of information but not in a database. Someone mentioned using binary or xml serialization. So I researched that and after two long 8 hour days of messing around with binary serialization and about a dozen different code techniques i finally found one that seems to work. I created a module that serializes two variables and appends them into a file. The same module also has a sub that deserializes the information from the file and displays in a message box. If needed I'll provide the code later.
Really the problem I am having is that my message box only displays the first entry into the file and no other. So I can append any number of variables to the file but every time I call the subroutine in my module it only displays the first entry. How do you read all of the file? Also can I search the file for a particular value of a variable? The variables are codependent. The two variables are simply a date and a string representing a changing code that corresponds to that specific date. So I'd like to be able to say search for a date and retrieve both the date and the code.
However I don't have any idea how to do this. Also the messagebox.show method is probably not the best way to illustrate the information in the file but I'm still new and I'm not sure the best way to show all the info in the file. For instance if I wanted to show the entire contents or just the codes corresponding to certain dates. I know a database is probably the better answer but I've gotten this far without one, lol, I'm too stubborn to change now. Once I figure this out, I'll switch and try the same technique with a database.
I built a prototype system with some database queries. Since it was just a prototype and I was very new to databases, I just used a direct string. This is the string I used and it works fine:
command = New OleDbCommand("SELECT * FROM " + prefix + "CanonicForms WHERE Type=1 AND Canonic_Form='" + item + "'", dictionary_connection)
Now, in putting it in a real system, I wanted to use the more secure parametized method, so after some googling I came up with this:
command = New OleDbCommand("SELECT * FROM @prefix WHERE Type=1 AND Canonic_Form=@form", dictionary_connection) command.Parameters.AddWithValue("@prefix", prefix + "CanonicForms") command.Parameters.AddWithValue("@form", item)
But all I get is an error for an incomplete query clause. What have I done differently between the two?
I am trying to Send an Email with an attachment (using Gmail) but I keep getting errors like "Operation Timed out" or Failure Sending Email". It was working earlier today but I found out that i needed to add Using statement because the email was having a file open that had to be deleted after it was sent but afterwards it doesn't work.
Here's what I have (Portion of it): Private Sub SendMailOneAttachment(ByVal un As String, ByVal pass As String, Optional ByVal smtp As String = "smtp.gmail.com") Using oAttach As Net.Mail.Attachment = New Net.Mail.Attachment((Environment.GetFolderPath(Environment.SpecialFolder.LocalApplicationData) & "\" & My.Computer.Name & "_" & fName & " .zip")) Dim client As SmtpClient = New SmtpClient(smtp) [Code] .....
The ports are correct I believe, no firewall up on my PC...
I am tring to send e-mail used VB 2008. Below is my code. The error message I am getting is "5 Failure sending mail at System.Net.mail.client.send(MailMessage message).I have two questions. 1.) What am I doing wrong? & 2.) Is there a way the get a more description error message.
message As New System.Net.Mail.MailMessage Dim mySmtpsvr[code].....
so now my question is how do i connect the WebSocketServer.cs to the index.aspx ?
As a start, all I'm trying to accomplish is just to get the Web Sockets working, and have the connection established, which then will alert("Stock Ticker Connection open ...");
how do I keep a Socket declared forever so i can call it in other methods?
All the tutorials i've read just have a server, client, server sends client message, client disconnects. What if I want to remain connected? I've tried making the sockets global but that didn't work somehow.