|
Hello,
I am using UDP protocol to broadcast a packet on the network. After I send this packet, some devices on the network answer with a UDP datagram packet containing some information.
My problem is that whenever one of these devices answer, (I know I get the packet because the Socket.Receive function returns me the data I am waiting for) I don't know who this packet is coming from. I am looking for a way to know the IP Address of the packet sender.
This is my code :
<br />
IPEndPoint Broadcast = new IPEndPoint(IP, 2000);<br />
EndPoint BroadcastEP = (EndPoint)Broadcast;<br />
<br />
socket = new Socket(System.Net.Sockets.AddressFamily.InterNetwork,<br />
SocketType.Dgram, ProtocolType.Udp);<br />
socket.SetSocketOption(SocketOptionLevel.Socket, SocketOptionName.Broadcast, 1);<br />
socket.SendTo(msg, 0, msg.Length, SocketFlags.None, BroadcastEP);<br />
Then, if I use the socket.Receive function, I get the payload of the packet but not the header information. Is there a way to get this information (Source's IP Address) with System.Net.Sockets or with System.Net.Sockets.UpdClient ?
I thought I could get this information by using socket.SetSocketOption(SocketOptionLevel.Socket, SocketOptionName.PacketInformation, ... but I just can't seem to figure out how to use it correctly.
If anyone knows how to do this, it would be greatly appreciated!
Hugo Migneron
|
|
|
|
|
Hi
When I run g++ (to compile) using process.start I get the error: "g++.exe: Main.cpp: No such file or directory"
If I run g++ using the same arguments from command prompt it runs fine. whats going wrong?
cheers
|
|
|
|
|
|
|
You need to specify the full path of the Main.cpp file when you run it using Process.Start, or, you need to set the current directory to the directory where Main.cpp resides before starting the process.
This is because a process spawned using Process.Start by default, has its current directory set to the application directory of the parent process.
Regards
Senthil
_____________________________
My Blog | My Articles | WinMacro
|
|
|
|
|
Thanks a lot! How can I "set the current directory to the directory where Main.cpp resides before starting the process"
Cheers again
|
|
|
|
|
You can use the ProcessStartInfo's WorkingDirectory property.
Regards
Senthil
_____________________________
My Blog | My Articles | WinMacro
|
|
|
|
|
|
Oops, sorry Senthil, I didn't see your reply to yourself where you already pointed this out!
Matt Gerrans
|
|
|
|
|
|
i have managed to make designcollection to work but i don't know how to create controls with the collection editor.
I have a Item, ItemCollection, ItemCollectionDesigner
an Item consist of text , int and picture
i want to attach a picturebox to it so that it auto generate on my usercontrol...
|
|
|
|
|
I was wondering if anyone can point me in the right direction to replicate the Internet Explorer-style Menu Bar in C# using Windows Forms?
I can easily create the menu using the toolbar control, but I run into problems trying to size the text correctly without the icon. Either I get too much space on the top (setting the toolbar TextAlign to Underneath), or I get too much space to the left (setting to Right). How do I get rid of the space?
~tekun
|
|
|
|
|
Hi, I have an lisview, when the lisview is filled, if it need draw vertical scroll, but if this happen, the horizontal scroll is drawin too to fit the columns with the vertical scroll width.
I would like to fix this resizing the columns with id the vertical scroll is visble.
How can I detect if vertical scroll is visible?
I have prove to catch the api messages in wnproc but I dont know wich message to detect.
Thank you!
La realidad no es más que impulsos eléctricos del cerebro - Morpheus
|
|
|
|
|
Hi,
We are using built in crystal reports for printing reports in pdf format.
We need to know how many pages of data is present in the pdf. basically we have to show "page # of #" in the report.
The problem is we cannot know how many pages are created once the report is shown inthe pdf.
Is there a way we can find how many pages are there in the final PDf created?
Prompt reply is appeciated.
YatinShah
Yatin Shah
Cell: 1 972 523 6333
|
|
|
|
|
How to prevent exiting application after clicking the OK button on Pocket PC?
I can handle the event but can't stop the application from closing.
thanks
|
|
|
|
|
i am make a login form,include both textbox and one button,one is username,other is password,if you input your correct username and password and click the button,you must close this form,and go into other form(this form is main form)
but i meet a troblue:
the button's click event:
NainForm mainForm = new MainForm();<br />
mainForm.Show();<br />
this.Close();
but the mainForm doesn't display,if replace the "mainForm.Show()" to "mainForm.ShowDialog()",the mainForm display,but the login form still display.
Can you help me?
|
|
|
|
|
Show() will allow the user to continue to use the application and bypass the login. ShowDialog() is a modal function, so the application can't be used until the dialog is dismissed. In your case of trying to obtain login data you would want to use this method.
In the OnLoad event for your main form create an instance of your login dialog and call ShowDialog on it from there. Obviously, you would check the DialogResult and handle it appropariately.
|
|
|
|
|
the first form closes because you call this.close. The first startup form probably has the stathread method which startsup the application. When you close this form it takes all the others forms with it cause it's under the same process. What you can do is move the stathread method to the login form and if login is succesful you can show the main form.
|
|
|
|
|
I've just discovered that C# doesn't support default paramters, is this true?
Why is this done?
tnx!
No hurries, no worries.
|
|
|
|
|
|
hey,
tnx!
No hurries, no worries.
|
|
|
|
|
Those arguments aren't very convincing, though. I think it is mostly a subjective stylistic decision aiming toward simplicity. Whether it is really better is probably more a matter of your personal programming style.
On the plus side, it is not too hard to work around:
string Transmogrify( string text, int cycles, bool superamalgamate )
{
}
string Transmogrify( string text, int cycles )
{
return Transmogrify( text, cycles, false );
}
string Transmogrify( string text )
{
return Transmogrify( text, 1 );
}
Unfortunately, this probably results in a little more maintenance trouble than it would with default parameters.
Matt Gerrans
|
|
|
|
|
i am trying to use a word template(.dot file) and a text file in a windows form using C#.i am aware how to extract data from the text file and open the word template.but what i am unable to do is to use the data from the text file in the word template's form fields.
can u tell me how i can replace the form fields with the value or data that i'm retrieving from the text file.
the template when open looks something like this....
Receipt Number : «ReceiptNo»
Card Number : «CardNo»
Member Name : «MemberName»
now,i've got to replace the fields «ReceiptNo»,«CardNo»
and «MemberName»...
i hope u've got an idea of what reply i'm expecting....
thank u...
|
|
|
|
|
I want to have the RGB bytes of a panel from a form to output what on the panel through the serial port
I can do that if the picture on my harddisk ,but the pic on the panel.
what can I do?
and why when I use these steps to get a screen shot it doesn't work, and give me an error message in debugging?
Surface backbuffer = device2.GetBackBuffer(0, 0, BackBufferType.Mono);
SurfaceLoader.Save("Screenshot.bmp", ImageFileFormat.Bmp, backbuffer);
backbuffer.Dispose();
thx
|
|
|
|
|