Click here to Skip to main content
15,891,864 members
Home / Discussions / C#
   

C#

 
GeneralRe: Keep from erasing working code in a project Pin
tonyonlinux18-Jan-10 20:29
tonyonlinux18-Jan-10 20:29 
GeneralRe: Keep from erasing working code in a project Pin
Bekjong18-Jan-10 22:02
Bekjong18-Jan-10 22:02 
AnswerRe: Keep from erasing working code in a project Pin
Ashfield18-Jan-10 21:09
Ashfield18-Jan-10 21:09 
Questionexport .m file from text file in VS2008 Pin
mohamadali&M18-Jan-10 18:10
mohamadali&M18-Jan-10 18:10 
AnswerRe: export .m file from text file in VS2008 Pin
Ashfield18-Jan-10 21:13
Ashfield18-Jan-10 21:13 
QuestionKeyEventArgs - differentiate control chars on numeric keypad [modified] Pin
cdesmarais18-Jan-10 12:21
cdesmarais18-Jan-10 12:21 
AnswerRe: KeyEventArgs - differentiate control chars on numeric keypad Pin
Luc Pattyn18-Jan-10 16:07
sitebuilderLuc Pattyn18-Jan-10 16:07 
Questionmanaged and unmanaged code............ Pin
3bood.ghzawi18-Jan-10 10:12
3bood.ghzawi18-Jan-10 10:12 
Hi all, pardon me, I need helping at the following code. When I run this code to get the IP address (at statement Console.WriteLine(ipAddress)) I get the IP address, subnet mask and network family at this maner:
169.254.25.129
255.255.0.0
255.255.255.255

but I need to get each of them uniqly (each one alone of others), and I need to get these using this code of the programe (this code from SharpPcap.2-1-1)….

Regards…………………………..

public Sockaddr(IntPtr sockaddrPtr)
{
// A sockaddr struct. We use this to determine the address family
PcapUnmanagedStructures.sockaddr saddr;

// Marshal memory pointer into a struct
saddr = (PcapUnmanagedStructures.sockaddr)Marshal.PtrToStructure(sockaddrPtr,
typeof(PcapUnmanagedStructures.sockaddr));

// record the sa_family for informational purposes
_sa_family = saddr.sa_family;

byte[] addressBytes;
if(saddr.sa_family == Pcap.AF_INET)
{

type = Type.AF_INET_AF_INET6;
PcapUnmanagedStructures.sockaddr_in saddr_in =
(PcapUnmanagedStructures.sockaddr_in)Marshal.PtrToStructure(sockaddrPtr, typeof(PcapUnmanagedStructures.sockaddr_in));
ipAddress = new System.Net.IPAddress(saddr_in.sin_addr.s_addr);
Console.WriteLine(ipAddress);

}
}// end of Sockaddr function

/////////////////////////////////////////////////////////////////////////////////
// A PcapUnmanagedStructures class is here:

public class PcapUnmanagedStructures
{
#region Unmanaged Structs Implementation


[StructLayout(LayoutKind.Sequential)]
public struct sockaddr
{
public UInt16 sa_family; /* address family */
[MarshalAs(UnmanagedType.ByValArray, SizeConst=14)]
public byte[] sa_data; /* 14 bytes of protocol address */
};

/// <summary>
/// Structure that holds an ipv4 address
/// </summary>
public struct in_addr
{
public UInt32 s_addr/*= 1111*/;
}

/// <summary>
/// Structure that holds an ipv4 address
/// 'struct sockaddr'
/// </summary>
[StructLayout(LayoutKind.Sequential)]
public struct sockaddr_in
{
public UInt16 sa_family; /* address family */
public UInt16 sa_port; /* port */
public in_addr sin_addr; /* address */
// TODO: would be great to be able to have the compiler take care of this for us
// but I'm not sure how to

// pad the size of sockaddr_in out to 16 bytes
[MarshalAs(UnmanagedType.ByValArray, SizeConst=8)]
private byte[] pad;
};
}// end of the PcapUnmanagedStructures class
AnswerRe: managed and unmanaged code............ Pin
Not Active18-Jan-10 11:42
mentorNot Active18-Jan-10 11:42 
QuestionHow to Select Drawn Objects Without Getting a System.Windows.Forms.Control Pin
GeniusMchlahla18-Jan-10 7:34
GeniusMchlahla18-Jan-10 7:34 
AnswerRe: How to Select Drawn Objects Without Getting a System.Windows.Forms.Control Pin
J. Dunlap18-Jan-10 13:11
J. Dunlap18-Jan-10 13:11 
GeneralRe: How to Select Drawn Objects Without Getting a System.Windows.Forms.Control Pin
GeniusMchlahla19-Jan-10 5:23
GeniusMchlahla19-Jan-10 5:23 
GeneralRe: How to Select Drawn Objects Without Getting a System.Windows.Forms.Control Pin
J. Dunlap19-Jan-10 6:27
J. Dunlap19-Jan-10 6:27 
QuestionEditing crystal reports at runtime Pin
kruegs3518-Jan-10 7:03
kruegs3518-Jan-10 7:03 
QuestionMessage Removed Pin
18-Jan-10 6:19
professionalN_tro_P18-Jan-10 6:19 
AnswerRe: Application Info and Error logging Pin
Eddy Vluggen18-Jan-10 7:19
professionalEddy Vluggen18-Jan-10 7:19 
GeneralMessage Removed Pin
18-Jan-10 8:19
professionalN_tro_P18-Jan-10 8:19 
GeneralRe: Application Info and Error logging Pin
Eddy Vluggen18-Jan-10 10:33
professionalEddy Vluggen18-Jan-10 10:33 
AnswerRe: Application Info and Error logging Pin
Not Active18-Jan-10 7:26
mentorNot Active18-Jan-10 7:26 
AnswerRe: Application Info and Error logging Pin
Bardy8518-Jan-10 8:33
Bardy8518-Jan-10 8:33 
AnswerRe: Application Info and Error logging Pin
Keith Barrow18-Jan-10 23:30
professionalKeith Barrow18-Jan-10 23:30 
QuestionPhone dialer application with C# Pin
Drs201018-Jan-10 4:16
Drs201018-Jan-10 4:16 
AnswerRe: Phone dialer application with C# Pin
Covean18-Jan-10 5:36
Covean18-Jan-10 5:36 
GeneralRe: Phone dialer application with C# Pin
Drs201018-Jan-10 13:11
Drs201018-Jan-10 13:11 
GeneralRe: Phone dialer application with C# [modified] Pin
Covean18-Jan-10 21:36
Covean18-Jan-10 21:36 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.