|
RAW means that i am generating the whole IP packet from scratch, including both the IP header, and the TCP header.
This is done using
socket = new Socket(AddressFamily.InterNetwork, SocketType.Raw, ProtocolType.IP);
socket.Connect(new IPEndPoint(IPAddress.None, 0));
socket.SetSocketOption(SocketOptionLevel.IP,SocketOptionName.HeaderIncluded,1);
and sending the whole packet stored in a buffer 'byte[] tmp', which contains source ip, destip, checksum...etc...in other words all the headers.
socket.Send(tmp);
As I mentioned before, the whole thing works fine for any packet, coz I checked them out with Ethereal. However when I change the protocol field in the IP header to 6, standing for TCP, I get the afore mentioned error, probably due to the XP update disabling raw packets.
thanks for your reply, not lazy at all;)
regards
dave
|
|
|
|
|
Just trying to get more background here but:
Do you have to use raw sockets? Don't the wrapper's provided by the .NET Framework do what you want?
Ed
|
|
|
|
|
Strictly speaking yes, I can simplyfy things and open a TCP client using .Net, howvever I was planning to implement my project with another final year project at a later stage, concerning TCP congestion control algorithims. This requires read and write access to the whole TCP layer, including the header.
So IDEALLY I stick to raw, but if nothing pops up I will have to do without.
Thanks m8
regards
Dav
|
|
|
|
|
Ok things are beginning to get clearer in my head now. Is WSACancelBlockingCall called by you or (as it appears) is fired from another program, i.e. this MS-9015 (wrong number I thing) thingy.
My first suggestion would be to if possible isolate the area of the network you're concerned with (i.e. don't connect it to the internet just have ideally two computers (or one with using the loopback interface) on the network. Then try the code while turning off all the network systems, i.e. firewalls, antivirus etc until you get to the one which is hopefully causing the problem. Once this has been established then we can delve further for a work-around.
Ed
|
|
|
|
|
Im not sending any WSACancelBlockingCall, so I assume this is due the update, at least this site lead me to think so: "http://www.microsoft.com/technet/prodtechnol/winxppro/maintain/sp2netwk.mspx#".
Good idea though, I will experiment Raw Sockets on my lan. Luckily I already got over the lan side by using an NDIS driver..and succesfully sent and received TCP over IP over Ethernet, and all other protocols. As regards firewalls and antivirus, I never had any of those.
|
|
|
|
|
|
So when you say you change the header to 6 representing TCP do you mean you do that to every packet or only TCP packets? You cannot change a UDP or most other packets to TCP. Make sure that isn't the case.
|
|
|
|
|
Im refering to the protocol field in the IP header. These are represented as
- 0: Reserved
- 1: Internet Control Message Protocol (ICMP)
- 2: Internet Group Management Protocol (IGMP)
- 3: Gateway-to-Gateway Protocol (GGP)
- 4: IP (IP encapsulation)
- 5: Stream
- 6: Transmission Control Protocol (TCP)
- 8: Exterior Gateway Protocol (EGP)
- 9: Private Interior Routing Protocol
- 17: User Datagram Protocol (UDP)
- 41: IP Version 6 (IPv6)
- 50: Encap Security Payload for IPv6 (ESP)
- 51: Authentication Header for IPv6 (AH)
- 89: Open Shortest Path First
I change it to 6 when the TCP layer contains TCP data, and this is correct as I am forwarding it directly from another user, and shows up correctly on Ethereal. As I mentioned before the problem is probably due to the Windows Update as seen on "http://www.microsoft.com/technet/prodtechnol/winxppro/maintain/sp2netwk.mspx#E5AAE"
Thanks,
Regards
Dav
|
|
|
|
|
Hello,
How do you get the filesize of an image (or images included in a web page), preferably using a WebBrowser control?
Thanks.
dan215
|
|
|
|
|
If you can get a reference to the Element which represents the image then I think you might be able to get it by using a method named something like GetAttributeValue (sorry I can't remember it exactly of the top of my head), if you call this with "width" and "height" as parameters I think you can get the height and width of the image (not the original image size but the size of the displayed image on the page).
Ed
|
|
|
|
|
Hi Ed,
Thanks for the quick reply.
You are correct: use the HtmlElement class and GetAttribute() method to get the image size with width & height as parameters. However I was referring to the "file" size (in bytes) of the image file. I know IE stores the webpage files in "Temporary Internet Files" folder as local cache but somehow programmatically it (OS?) does not allow the files to be read. However you can manually see these files using Windows Explorer.
Any thoughts?
Thanks.
dan215
|
|
|
|
|
How about:
string uri = @"the image filename here";
WebRequest request = WebRequest.Create(uri);
WebResponse response = request.GetResponse();
Console.WriteLine("Content.Length={0}", response.ContentLength);
You can use HtmlElement.GetAttribute("src") to get the path to the image. I shouldn't think that this re-downloads the file but you never know.
[mod]It doesn't unless my 512k line just downloaded 650 meg in 1/2 a sec [/mod]
Ed
-- modified at 19:31 Monday 17th April, 2006
|
|
|
|
|
Unfortunately, response.ContentLength only gives you the "HTML text" size. It does not include the image(s).
dan215
|
|
|
|
|
If you pass the image file URI which you want to get the size of then it will. I tested this on a PDF hosted on our website.
Ed
|
|
|
|
|
Hi Ed,
Thanks. You are correct. My dilemma is I'm using WebBrowser control first to navigate to the webpage to get all the images names via HtmlDocument/HtmlElement classes. If I use WebRequest/WebResponse, I'm essentially doing two requests from the server. I'm thinking if there a way to just do these things once. I don't have to use WebBrowser control but it helps in easily parsing the desired attributes.
Appreciate your help. Things are looking up!
dan215
BTW: I tried accessing a local image and I got a "401" not authorized error message.
-- modified at 13:51 Tuesday 18th April, 2006
|
|
|
|
|
dan215 wrote:
BTW: I tried accessing a local image and I got a "401" not authorized error message.
Is this a problem or just a point you cared to share?
Glad to see things are sorting themselves out.
Ed
|
|
|
|
|
Well, it was a problem but I got it fixed by changing the Authentication Method of my localhost webpage from Integrated Windows Authentication to Anonymous Access just for testing purposes.
I haven't figured out yet how to get the byte size in 1 request but 2 requests is ok for now.
Thanks a lot Ed.
dan215
|
|
|
|
|
Unless you already know the uri of the image/file you want to get the size of you cannot make it in one request because you have to have one to find the location of the file (i.e. a request to the html file to find the image path) and then a request to the image file for the file size.
Ed
|
|
|
|
|
I agree. Another way I thought I could do was to read the image file info from the Temporary Internet Files folder but I can't use the FileInfo class since XP does not seem to allow any file in that directory be read except desktop.ini. If I can circumvent this that would resolve the issue.
Any ideas?
dan215
|
|
|
|
|
dan215 wrote: Any ideas?
Not really, apart from that my view of accessing the Temporary Internet Files is a bad idea on the whole. There are too many ifs and buts.
The thing which I should be improved is trying to eliminate the WebBrowser if you're simply using it for accessing the html to get the filename and not actually displaying it because my guess it'll be very resource hungry.
If you know that the image paths will be specified in the html page then it'd probably be more efficient to make a WebRequest or use WebClient to "download" or read the file and then use a simple parser or regular expressions to extract the image file, this way you're not creating a UI control and then not displaying it.
Just my two pennies
Ed
|
|
|
|
|
I agree with you.
Thanks.
dan215
|
|
|
|
|
That's good to know
Ed
|
|
|
|
|
Hey guys, I have to tables and I want to make a selection from both tables
Table 1: Customer >> Name and number (my main table)
Table 2: Order >> Order
with the select command i select them, not I want to show it in DataGridView, but i can fill data gried with one table
DataGridView1.dataSource = MyDS.Tables["Customer"];
but when I fill in the DataGridView, It authomatically adds the new Row from Order Table(i want to change the header but its not possible because it brings it driectly from database).
I used this command to add a column in my dataSet
MyDS.Tables["Customer"].Columns.Add("Order");
what I dunno how to do this, to show the data in the column Order from Order table in my new Column that I have created.
Mr.K
|
|
|
|
|
You're being a little vague, so hopefully I'll be able to get some clarification. Are you trying to join two tables and then display the resulting join in a DGV? If so, can you give us the query string that you use to retrieve the data. Also, have you stepped through your code and ensured the query returns what you want?
|
|
|
|
|
I fixed that Problem, I have this question
we have this command for DataGrid
dataGrid1.SetDataBinding(MyDataSet, "MyTable");
Do we have the same command for DGV ? Or something equivalant that does the sam thing ?
Mr.K
|
|
|
|