|
Why UDP?
UDP does not offer reliability. But In case of file transfer reliability is important.
Are you sure its UDP? not TCP?
|
|
|
|
|
yeah,UDP
I want to create a program that can send the file. but when the file is received the client, a large bit of data is not the same. then resend the request until the server successfully.
if you have the source code in c?
for my coursework ...thank's
|
|
|
|
|
Brillian Kharisma wrote: you have the source code in c? for my coursework
All the more reason for you to do it yourself. Ask us specific questions about specific code problems to help you. No one here is going to do it for you.
Why is common sense not common?
Never argue with an idiot. They will drag you down to their level where they are an expert.
Sometimes it takes a lot of work to be lazy
Individuality is fine, as long as we do it together - F. Burns
|
|
|
|
|
UDP is NOT typically used for file transfers because it's not reliable. If you add parity, you can detect errors and request resends, but you're just replicating TCP at that point.
Brillian Kharisma wrote: if you have the source code in c?
for my coursework ...thank's
You need to do your own homework. Sorry.
|
|
|
|
|
The only advantage you gain from UDP is speed. I use UDP for realtime hardware status updates but I never use it to transfer files. Why not use TCP as others have suggested. It was designed for streaming files. You could also check out named pipes.
|
|
|
|
|
I want to get two front and profile picture of a person then make 3D Head model of it using Visual C++ and openGL.
How could I start?
|
|
|
|
|
Look Creating 3D Head model open GL C++here[^]
You talk about Being HUMAN. I have it in my name
AnsHUMAN
|
|
|
|
|
|
Hello everyone!
I have a EasyN ip Camera and I want to take the picture as .Jpg. The url that displays the image in my browser is http://192.168.1.xxx:xx/videostream.cgi.
After many hours searching in the internet I found this interest tutorial Camera Vision - video surveillance on C#,
but because I do not know much about Visual Studio did not help me very much.
Specifically, I have created a Visual C # Console Application but when I try to debugging shows some errors like: "The type or name 'HttpWebRequest' could not be found (are you missing a using directive or an assembly reference?)".
What am I doing wrong and the program not works?
Initially, What I want is the picture is automatically saved in my hard disk as .Jpg format. How can this happen?
Here is my code
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace ConsoleApplication4
{
class Program
{
static void Main(string[] args)
{
string sourceURL = "http://192.168.1.xxx:xx/videostream.cgi";
byte[] buffer = new byte[100000];
int read, total = 0;
HttpWebRequest req = (HttpWebRequest)WebRequest.Create(sourceURL);
WebResponse resp = req.GetResponse();
Stream stream = resp.GetResponseStream();
while ((read = stream.Read(buffer, total, 1000)) != 0)
{
total += read;
}
Bitmap bmp = (Bitmap)Bitmap.FromStream(
new MemoryStream(buffer, 0, total));
}
}
}
It would be valuable any of yours help!
Thank you!
|
|
|
|
|
Your first problem is that you have posted this in the C++ forum rather than the C#[^] one. However the error message means that a reference is missing from your project.
[edit]Right click with your mouse on the References section of Project explorer and select "Add Reference ...", then find the assembly named "System" in the .NET section, and add it to your project.
You will also need to add the following statement to the top of your source code:
using System.Net;
[/edit]
Unrequited desire is character building. OriginalGriff
I'm sitting here giving you a standing ovation - Len Goodman
|
|
|
|
|
Thanks for your answer! I apologize for my mistake ...
I've done all everything you said and actually decrease errors. However there are still 5 errors relating some wrong commands. For example, some of errors are:
"The type or name 'Stream' could not be found (are you missing a using directive or an assembly reference?)"
"The type or name 'Bitmap' could not be found (are you missing a using directive or an assembly reference?)"
"The type or name 'MemoryStream' could not be found (are you missing a using directive or an assembly reference?)"
Do you know how experiencing this error?
|
|
|
|
|
Eventually was missing the command using System.IO;
So the following 2 errors are gone
"The type or name 'Stream' could not be found (are you missing a using directive or an assembly reference?)".
"The type or name 'MemoryStream' could not be found (are you missing a using directive or an assembly reference?)".
Now the problem is with the command Bitmap
|
|
|
|
|
Synodiporos wrote: Now the problem is with the command Bitmap
All of these classes are described in MSDN. Here is the link to Bitmap [^]; the others are easy to find.
And, more usefully, MSDN comes in many languages other than American.
Unrequited desire is character building. OriginalGriff
I'm sitting here giving you a standing ovation - Len Goodman
|
|
|
|
|
Thanks for your advice Richard!
I have fix all the mistakes and now the program is running. The problem now is that i take a warning in this line:
while ((read = stream.Read(buffer, total, 1000)) != 0)
The warning says “Specified argument was out of the range of valid values.
Parameter name: size”
I changed the size of the variable to a larger but the problem remains. I do not know what else should I do now ...
|
|
|
|
|
Forget it! Once I found a solution for this ...
int bytesToRead = 1000;
while ((read = stream.Read(buffer, total, bytesToRead)) != 0)
{
total += read;
bytesToRead -= read;
}
Perhaps the variable "bytesToRead" should be reduced in the loop ...
|
|
|
|
|
I am coming again to the thread to asked you a little help.
I have make all necessary changes and now my program is running without any errors or warnings. But i can not see the image! Specifically I created a form with a button and a pictureBox. I want when I click the button to save the image and display it in the pictureBox.
Why cannot display the image? Here is my example:
public Form1()
{
InitializeComponent();
}
private void button1_Click(object sender, EventArgs e)
{
string sourceURL = "http://192.168.1.xxx:xx/videostream.cgi";
byte[] buffer = new byte[200000];
int read, total = 0;
HttpWebRequest req = (HttpWebRequest)WebRequest.Create(sourceURL);
req.Credentials = new NetworkCredential("Admin", "xxxx");
WebResponse resp = req.GetResponse();
Stream stream = resp.GetResponseStream();
int bytesToRead = 1000;
while ((read = stream.Read(buffer, total, bytesToRead)) != 0)
{
total += read;
bytesToRead -= read;
}
Bitmap bmp = (Bitmap)Bitmap.FromStream(stream);
bmp.Save("C:\\image.jpg");
pictureBox1.Image = bmp;
}
private void pictureBox1_Click(object sender, EventArgs e)
{
}
Can you help me in this?
|
|
|
|
|
What type of object is pictureBox1 and are you sure that the statement
pictureBox1.Image = bmp; sets the object correctly? Note that the bmp object gets destroyed as soon as the button1_Click() function terminates.
Unrequited desire is character building. OriginalGriff
I'm sitting here giving you a standing ovation - Len Goodman
|
|
|
|
|
Thanks for your help!
Now, I can get the image from the camera ...
|
|
|
|
|
While it's not a solution to your question, I'd like to point something out.
Any network address that begins with 192.168 is an address in a private network. What this means is that, only computers in that network may access other devices within it.
As such, it's entirely safe for me to say that the IP of the machine I'm typing on right now is 192.168.43.156 , and that the address of my gateway (the 'side' of the router that my pc can see) is 192.168.43.1
If I browse to a 'WhatsMyIp' type of website, the address returned is the IP that the 'other side' of my router has - the address that CAN be seen from anyone connected to the web. This address is NOT safe to share publicly.
See here for more on private networks: http://en.wikipedia.org/wiki/Private_network[^]
|
|
|
|
|
Hi Guys,
Is there any way to validate a socket descriptor before doing any IO on it?
~ Vikram S
|
|
|
|
|
What do you mean by validate, against what criteria?
Unrequited desire is character building. OriginalGriff
I'm sitting here giving you a standing ovation - Len Goodman
|
|
|
|
|
For example I am holding an client socket connected with some server. The server goes down or network goes down. Before doing any action I want to know is the socket in good state.
|
|
|
|
|
Ah, the age old problem.
Look, when two asynchronous processes are communicating things can go wrong at any moment. Even if there was a great way for you to check to see if the socket is in a good state, 1/2 microsecond later it could go bad so you'd still have to handle the "bad state" case when you access the socket connection. Just because it was in a good state an instant ago doesn't mean it still is, that's the nature of asynchronous communications and networks.
The falicy is expecting orderly things to happen in a disorderly world. Better to concentrate your efforts in dealing with the "error conditions", trying to communicate with the socket and discovering it's in a "bad state" by handling the failure returns, timeouts, etc. Handle the "disorderly shutdown" cases and you'll discover that the "orderly shutdown" cases fall out nicely.
|
|
|
|
|
Besides the other reply note as well that there is no way to insure that a socket is working without sending something (reading will not work.)
|
|
|
|
|
I have 3 buttons on a dialod with tab stop property = false, sometimes if I click all buttons in random order a hover effect (round blue) comes around the 2 buttons simultaneouly. It don't disappear even after mouse is not on any button. I think It should not come. Can you please suggest any workaround?
|
|
|
|