Click here to Skip to main content
15,899,124 members
Home / Discussions / C#
   

C#

 
QuestionReading a PDF File Pin
Anil Kumar.Arvapalli19-Sep-10 20:45
Anil Kumar.Arvapalli19-Sep-10 20:45 
AnswerRe: Reading a PDF File Pin
R. Giskard Reventlov19-Sep-10 20:49
R. Giskard Reventlov19-Sep-10 20:49 
Questionproblem reading from app.config Pin
Jassim Rahma19-Sep-10 6:23
Jassim Rahma19-Sep-10 6:23 
AnswerRe: problem reading from app.config Pin
Luc Pattyn19-Sep-10 7:00
sitebuilderLuc Pattyn19-Sep-10 7:00 
QuestionRe: problem reading from app.config Pin
i.j.russell19-Sep-10 20:58
i.j.russell19-Sep-10 20:58 
QuestionHow to use SetPortVal() and GetPortVal() of winio?? Pin
shushi.lin19-Sep-10 4:39
shushi.lin19-Sep-10 4:39 
AnswerRe: How to use SetPortVal() and GetPortVal() of winio?? Pin
Dave Kreskowiak19-Sep-10 7:24
mveDave Kreskowiak19-Sep-10 7:24 
QuestionTCP Header structure Pin
95ulisse19-Sep-10 3:02
95ulisse19-Sep-10 3:02 
Hi,
I'm trying to use raw sockets, but I have some problems with the 3-way handshake.

The problem is that the server doesn't answer me when I send the SYN packet.
Maybe, it's a class problem. This is the class for the TCP header:

public enum TcpHeaderFlags : byte
{
    CWR = 128,
    ECE = 64,
    URG = 32,
    ACK = 16,
    PSH = 8,
    RST = 4,
    SYN = 2,
    FIN = 1,
    None = 0
}

public class TcpHeader : ProtocolHeader
{

    //Fields
    public UInt16 SourcePort = 80;
    public UInt16 DestinationPort = 80;
    public UInt32 SequenceNumber = 0;
    public UInt32 AcknowledgmentNumber = 0;
    private byte DataOffsetAndReserved = 0;
    public TcpHeaderFlags Flags = TcpHeaderFlags.None;
    public UInt16 WindowSize = UInt16.MaxValue;
    public UInt16 Checksum = 0;
    public UInt16 UrgentPointer = 0;

    public override byte[] GetProtocolPacketBytes(byte[] payLoad)
    {
        //Stream
        MemoryStream memStream = new MemoryStream();

        //Buffer
        byte[] buffer = null;

        //Source port
        buffer = BitConverter.GetBytes(SourcePort);
        memStream.Write(buffer, 0, buffer.Length);

        //Destination port
        buffer = BitConverter.GetBytes(DestinationPort);
        memStream.Write(buffer, 0, buffer.Length);

        //Sequence number
        buffer = BitConverter.GetBytes(SequenceNumber);
        memStream.Write(buffer, 0, buffer.Length);

        //Ack number
        buffer = BitConverter.GetBytes(AcknowledgmentNumber);
        memStream.Write(buffer, 0, buffer.Length);

        //Data offset and reserved
        memStream.Write(new byte[] { DataOffsetAndReserved }, 0, 1);

        //Flags
        memStream.Write(new byte[] { (byte)Flags }, 0, 1);

        //Window size
        buffer = BitConverter.GetBytes(WindowSize);
        memStream.Write(buffer, 0, buffer.Length);

        //Checksum
        buffer = BitConverter.GetBytes(Checksum);
        memStream.Write(buffer, 0, buffer.Length);

        //Urgent pointer
        buffer = BitConverter.GetBytes(UrgentPointer);
        memStream.Write(buffer, 0, buffer.Length);

        //Return
        return memStream.ToArray().Concat(payLoad).ToArray();
    }

}


So, my question is:
please, can you give me a working class for the tcp header??

PS:
I've taken the IP header class from this site:
http://www.winsocketdotnetworkprogramming.com/clientserversocketnetworkcommunication8chap.html[^]
AnswerRe: TCP Header structure Pin
Dave Kreskowiak19-Sep-10 7:21
mveDave Kreskowiak19-Sep-10 7:21 
GeneralRe: TCP Header structure Pin
95ulisse19-Sep-10 9:08
95ulisse19-Sep-10 9:08 
GeneralRe: TCP Header structure Pin
Dave Kreskowiak19-Sep-10 9:56
mveDave Kreskowiak19-Sep-10 9:56 
QuestionPInvoke Pin
Saksida Bojan19-Sep-10 0:08
Saksida Bojan19-Sep-10 0:08 
AnswerRe: PInvoke Pin
Luc Pattyn19-Sep-10 3:23
sitebuilderLuc Pattyn19-Sep-10 3:23 
GeneralRe: PInvoke Pin
Saksida Bojan19-Sep-10 3:59
Saksida Bojan19-Sep-10 3:59 
AnswerRe: PInvoke Pin
Luc Pattyn19-Sep-10 4:16
sitebuilderLuc Pattyn19-Sep-10 4:16 
QuestionWhy i get an exception on this code ? ( code attached ) Pin
Yanshof18-Sep-10 21:53
Yanshof18-Sep-10 21:53 
AnswerRe: Why i get an exception on this code ? ( code attached ) Pin
Paul Michalik18-Sep-10 23:32
Paul Michalik18-Sep-10 23:32 
GeneralRe: Why i get an exception on this code ? ( code attached ) Pin
Yanshof18-Sep-10 23:49
Yanshof18-Sep-10 23:49 
AnswerRe: Why i get an exception on this code ? ( code attached ) Pin
Saksida Bojan19-Sep-10 1:19
Saksida Bojan19-Sep-10 1:19 
AnswerRe: Why i get an exception on this code ? ( code attached ) Pin
Manfred Rudolf Bihy19-Sep-10 22:11
professionalManfred Rudolf Bihy19-Sep-10 22:11 
Questionexcel import wizard (fixed line) Pin
eyeshield2118-Sep-10 15:16
eyeshield2118-Sep-10 15:16 
QuestionAnyone have an RDLC Example with SQL Server 2008 R2 Pin
gmhanna18-Sep-10 7:01
gmhanna18-Sep-10 7:01 
AnswerRe: Anyone have an RDLC Example with SQL Server 2008 R2 Pin
Mycroft Holmes18-Sep-10 17:16
professionalMycroft Holmes18-Sep-10 17:16 
QuestionCustom look for NumericUpDown control Pin
Mazdak18-Sep-10 1:05
Mazdak18-Sep-10 1:05 
AnswerRe: Custom look for NumericUpDown control Pin
OriginalGriff18-Sep-10 6:13
mveOriginalGriff18-Sep-10 6:13 

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.