Current location: Hot Scripts Forums » Programming Languages » Windows .NET Programming » Send Packet over network


Send Packet over network

Reply
  #1 (permalink)  
Old 09-17-11, 02:29 PM
deadManN deadManN is offline
Newbie Coder
 
Join Date: Sep 2009
Posts: 60
Thanks: 1
Thanked 0 Times in 0 Posts
Send Packet over network

hello there, long time ago, more than a year, i gain my answer from one moderator in here (C# section or such) so once again i back here, and i hope some one help me :-s

i start writing a game for my self to improve my own knowledge and also have thing to say about network programming which is required the must today....

so i make 3 class :
  1. TransmitionReciever
  2. TransmitionSender
  3. Pocket

i had no idea how it work i just scroll throgh namespaces, and then classes, and i find one of them... i still had now idea how to use it, so i start writing, till i reach to where i should read my packet..

but then i find out ... wow ... it's buffer reader writer , and the buffer is not serialized to object, but it's array of bytes... and seem (since class name and type) it work like a file, and every one write in it, so it will be full soon :-s

but what i need to do is :
  1. stablish connection
  2. if connection stablished, try to read my packet, if it reached successfully
  3. also send my packet to host

i write this code till i find out it's not what i'm looking for :-s
can you help me to write something better...

yeah, buffer reader writer is fast, but think of one day, i start writing program which need to monitor a system, or transmit image and ....
so i need to send and recieve object...


Code:
using System;
using System.Collections.Generic;
using System.Text;

namespace LOCAL_SERVER_GAME
{
    class TransmiterReciever
    {
        System.Net.Sockets.TcpClient tc = new System.Net.Sockets.TcpClient();
        System.Net.Sockets.NetworkStream ns = new System.Net.Sockets.NetworkStream();
        
        Byte[] buffer;
        public TransmiterReciever()
        {
            tc.ReceiveBufferSize = sizeof(Pocket);
            buffer = tc.ReceiveBufferSize;
        }

        public Boolean connect(Int32 port, String address)
        {
            Byte[] b=Byte.Parse(address);
            tc.Connect(new System.Net.IPAddress(b), port);
            return (tc.Connected) ? true : false;
        }

        public Pocket recieveData()
        {
            ns=tc.GetStream();
            if (ns.CanRead)
            {
             
            }
        }
    }
}
Reply With Quote
  #2 (permalink)  
Old 09-18-11, 05:23 PM
deadManN deadManN is offline
Newbie Coder
 
Join Date: Sep 2009
Posts: 60
Thanks: 1
Thanked 0 Times in 0 Posts
Holy NO!!!

this forum is dead :'(

where should i go now?
MSDN is like hell, they never answer :-s
and no else where i know :-s
Reply With Quote
Reply

Bookmarks


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
a.c. 50Hz voltage asm trouble steph6 Other Languages 0 04-09-08 05:17 AM
Read file then send packet to another server Boylett Script Requests 3 12-12-06 06:20 PM


All times are GMT -5. The time now is 02:20 PM.
vBulletin® Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.