Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
U

User 3491102

@User 3491102
About
Posts
16
Topics
2
Shares
0
Groups
0
Followers
0
Following
0

Posts

Recent Best Controversial

  • Sockets in C#
    U User 3491102

    "Hi, I have the client and Udp server communicate with each other.Now im not getting the exception "The existing connection was forcibly closed by the remote host".This is because i have defined the server in a separate project." - Most likely because you are using UDP and not TCP (if thats what was used before) UDP doesnt care about "connections" etc, it just sends/recieves to/from endpoints. Not because you moved the server part into a seperate project... "The client is now able to communicate with 1 server at one ip and port.But i want the client to call another UDP server at another port but same ip.For eg:the client is communicating with udp server at port 10001.After every 15 secs the client should connect with the servers at different ports(10002,10003 etc)" - You will have to define another endpoint for the UDP sending socket (client) with a different port, tis all. If you still are having problems, please post up some code; it might help clear things up.

    modified on Saturday, March 14, 2009 1:30 PM

    C# csharp sysadmin question

  • doubt
    U User 3491102

    No, but you could milk a heck of alot of information about topics if you designed a bot to do it for multiple forums/locations...

    C# security sysadmin question

  • doubt
    U User 3491102

    Original post:Guys, cant you tell a bot when you see one? EDIT: Correction! "Yo Member 3493799, cant you tell a human when you see one?" ;P

    C# security sysadmin question

  • socket programing
    U User 3491102

    What protocol are you using?

    C# security beta-testing help question code-review

  • Blackhole string!
    U User 3491102

    Opening a good old Port may be the solution to many a networking problem ;-)

    C# question lounge workspace

  • Blackhole string!
    U User 3491102

    Cheers, that makes sense, will change it accordingly.

    C# question lounge workspace

  • Blackhole string!
    U User 3491102

    Used breakpoints, saw the values and they were correct. newText was highlighted in red though when I got to the" chatView.Text = newText" (dont know what that means: VS2008). myName = "test" myText = "ETST13245"

    newText "\r\Test\0\0\0\0\0\0\0: ETST13245\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" string

    C# question lounge workspace

  • Blackhole string!
    U User 3491102

    Tried it, didnt work :( Heres the packet decoding scheme: myName = dataSender myText = dataMessage

    [StructLayout(LayoutKind.Sequential, Pack = 1)]
    public struct rawCncPacket
    {
    // IP
    public byte IPVerLen;
    public byte IPTOS;
    public short IPLength;
    public short IPID;
    public short IPOffset;
    public byte IPTTL;
    public byte IPProtocol;
    public short IPChecksum;
    public int IPSrcAddr;
    public int IPDestAddr;
    // UDP
    public short UDPsourcePort;
    public short UDPdestPort;
    public short UDPLength;
    public short UDPcheckSum;
    // CNC
    public int CNCpacketDirection;
    public int CNCpacketNumber;
    public int CNCpacketSource;
    public int CNCpacketDest;
    public short CNCpacketPort;
    public short CNCpacketHeaderEnd;
    // Data
    public byte dataType; // 1
    public byte[] dataSenderBytes;
    public string dataSender; // 12
    public byte[] dataMessageBytes;
    public string dataMessage; // 24
    public int dataPackOne;
    public int dataPackTwo;
    public byte dataPackEnd;

                    public rawCncPacket(byte\[\] packet)
                    {
                        // IP Header section
                        System.IO.MemoryStream stm = new System.IO.MemoryStream(packet, 0, 94);
                        System.IO.BinaryReader rdr = new System.IO.BinaryReader(stm);
                        IPVerLen = rdr.ReadByte();
                        IPTOS = rdr.ReadByte();
                        IPLength = rdr.ReadInt16();
                        IPID = rdr.ReadInt16();
                        IPOffset = rdr.ReadInt16();
                        IPTTL = rdr.ReadByte();
                        IPProtocol = rdr.ReadByte();
                        IPChecksum = rdr.ReadInt16();
                        IPSrcAddr = rdr.ReadInt32();
                        IPDestAddr = rdr.ReadInt32();
                        // UDP header section
                        UDPs
    
    C# question lounge workspace

  • Blackhole string!
    U User 3491102

    I know! Nothing works in combination. Heck, even when I remove the newline stuff and just have myName + myText, it only shows myName... weirdest thing ever..

    C# question lounge workspace

  • Multi-Threading Question
    U User 3491102

    Did you use Socket.beginAccept?

    C# question csharp com sysadmin tools

  • Blackhole string!
    U User 3491102

    Below is my code to add a chat message to a multiline text box. I have tested the parameters, when I run them on messagebox's they output the proper value, but when I combine them: "chatView.Text = chatView.Text + Environment.NewLine + myName + ": "+ myText;" Only "myName" shows up on each line. What am i doing wrong?

    public delegate void chatMessageCallBack(string myName, string myText);
    private void chatMessage(string myName, string myText)
    {
    chatView.Text = chatView.Text + Environment.NewLine + myName + ": "+ myText;
    }
    private void addChatMessage(string myName, string myText)
    {
    if (chatView.InvokeRequired)
    {
    chatMessageCallBack d = new chatMessageCallBack(chatMessage);
    Invoke(d, new object[] { myName, myText });
    }
    else
    {
    chatView.Text = chatView.Text + Environment.NewLine + myName + ": " + myText;
    }
    }

    C# question lounge workspace

  • Compile error: Using strings inside Struct with LayoutKind.Explicit
    U User 3491102

    Just a note for anyone else who comes across this issue and sees this thread: The solution provided by Luc does NOT WORK with LayoutKind.Explicit, it only works with LayoutKind.Sequential, and with the FieldOffset()'s removed (obviously). This is the compiling + working code:

    [StructLayout(LayoutKind.Sequential, Pack = 1, Size = 66, CharSet = CharSet.Ansi)]
    public struct chatOne
    {

                    public int packetType; //4
                    public int packetNumber; //4
                    public int packetSource; //4
                    public int packetDestination; //4
                    public short packetPort; // 2
                    public ushort packetInfoEnd; // 2
                    public byte dataId; // 1
                    \[MarshalAs(UnmanagedType.ByValTStr, SizeConst = 11)\]
                    public string dataSender; // 11
                    public byte dataPadOne; // 1
                    \[MarshalAs(UnmanagedType.ByValTStr, SizeConst = 23)\]
                    public string dataMessage; // 23
                    public short dataPart; // 2
                    public int dataEndCodeOne; // 4
                    public int dataEndCodeTwo; // 4
    
                    public chatOne(int dst, short port, string sender, string message)
                    {
                        packetType = 1192961;
                        packetNumber = 0;
                        packetSource = 0;
                        packetDestination = dst;
                        packetPort = IPAddress.HostToNetworkOrder(port);
                        packetInfoEnd = 43521;                      
                        dataId = 10;
                        dataSender = sender;
                        dataPadOne = 0;
                        dataMessage = message;
                        dataPart = 206;
                        dataEndCodeOne = 10209786;
                        dataEndCodeTwo = 6658;
                    }
                }
    
    C# help lounge

  • Compile error: Using strings inside Struct with LayoutKind.Explicit
    U User 3491102

    Thank you! It worked perfectly! Very much appreciated

    C# help lounge

  • How to add multiple controls at runTime ?
    U User 3491102

    I would suggest: 1. Finding the previously added button and setting the new X relative to that through iteration/foreach. 2. Referencing the last control in the Controls list (might be the last one) using the length/count of the list.

    modified on Sunday, February 22, 2009 9:12 AM

    C# help tutorial question

  • How to add multiple controls at runTime ?
    U User 3491102

    Looks like your building buttons on top of each other. Isn't it always going to set the location to the same place for every button?

    C# help tutorial question

  • Compile error: Using strings inside Struct with LayoutKind.Explicit
    U User 3491102

    Getting compile (Overwritten area/contains Object field @ offset 21) I want a string that is of length 11 (sender) and a string that is of length 23 (message). Any help is appreciated; I cant see the problem. [StructLayout(LayoutKind.Explicit, Pack = 1, Size = 66, CharSet = CharSet.Ansi)] public struct chat { [FieldOffset(0)] public int packetType; //4 [FieldOffset(4)] public int packetNumber; //4 [FieldOffset(8)] public int packetSource; //4 [FieldOffset(12)] public int packetDestination; //4 [FieldOffset(16)] public short packetPort; // 2 [FieldOffset(18)] public ushort packetInfoEnd; // 2 [FieldOffset(20)] public byte dataId; // 1 [FieldOffset(21)] public string dataSender; // 11 [FieldOffset(32)] public byte dataPadOne; // 1 [FieldOffset(33)] public string dataMessage; // 23 [FieldOffset(56)] public short dataPart; // 2 [FieldOffset(58)] public int dataEndCodeOne; // 4 [FieldOffset(62)] public int dataEndCodeTwo; // 4 public chat(int dst, short port, string sender, string message) { packetType = 1192961; packetNumber = 0; packetSource = 0; packetDestination = dst; packetPort = IPAddress.HostToNetworkOrder(port); packetInfoEnd = 43521; dataId = 10; dataSender = sender; dataPadOne = 0; dataMessage = message; dataPart = 206; dataEndCodeOne = 10209786; dataEndCodeTwo = 6658; } }

    C# help lounge
  • Login

  • Don't have an account? Register

  • Login or register to search.
  • First post
    Last post
0
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups