Click here to Skip to main content
15,898,770 members
Home / Discussions / C#
   

C#

 
GeneralRe: C# Packet Loss Pin
Member 114965274-Mar-15 4:59
Member 114965274-Mar-15 4:59 
GeneralRe: C# Packet Loss Pin
Gerry Schmitz4-Mar-15 11:57
mveGerry Schmitz4-Mar-15 11:57 
QuestionHow to import excel sheet data into postgresql database table in C# Pin
sandy reddy3-Mar-15 2:29
sandy reddy3-Mar-15 2:29 
AnswerRe: How to import excel sheet data into postgresql database table in C# Pin
manchanx3-Mar-15 2:38
professionalmanchanx3-Mar-15 2:38 
QuestionRe: How to import excel sheet data into postgresql database table in C# Pin
ZurdoDev3-Mar-15 2:46
professionalZurdoDev3-Mar-15 2:46 
AnswerRe: How to import excel sheet data into postgresql database table in C# Pin
V.3-Mar-15 20:19
professionalV.3-Mar-15 20:19 
QuestionDoes the .Net scheduled Timer has a vb version? Pin
PHdeviloth2-Mar-15 20:55
PHdeviloth2-Mar-15 20:55 
QuestionRe: Does the .Net scheduled Timer has a vb version? Pin
Richard MacCutchan2-Mar-15 21:25
mveRichard MacCutchan2-Mar-15 21:25 
AnswerRe: Does the .Net scheduled Timer has a vb version? Pin
F-ES Sitecore2-Mar-15 22:02
professionalF-ES Sitecore2-Mar-15 22:02 
AnswerRe: Does the .Net scheduled Timer has a vb version? Pin
ZurdoDev3-Mar-15 2:45
professionalZurdoDev3-Mar-15 2:45 
QuestionNeed help on FTPS file transmission using X509 Certificates Pin
Satheesh Kumar Subramanian2-Mar-15 18:03
Satheesh Kumar Subramanian2-Mar-15 18:03 
AnswerRe: Need help on FTPS file transmission using X509 Certificates Pin
Richard MacCutchan2-Mar-15 21:24
mveRichard MacCutchan2-Mar-15 21:24 
QuestionStreamReader in TcpListener Pin
Member 114922552-Mar-15 7:14
Member 114922552-Mar-15 7:14 
Hello,
I am currently developing a Quiz that has to send the result of each participant to me via a TCP-connection. On the server computer (with the "master" application) the results get evaluated. It is of vital importance that the results are transmitted rapidly (that's why TCP rather than uploading result or such).

The connectin itself works, I just struggle with the StreamReader (and StreamWriter). This is my code as of now:

Client-Sending:
C#
private void onButtonClick() {
TcpClient client;            
client = new TcpClient("127.0.0.1", 25543);

            StreamWriter writer = new StreamWriter(client.GetStream());
            writer.Write("Test");
            writer.Flush();
        }


Server-Receiving (runs in Timer):

C#
TcpClient client = new TcpClient();
        TcpListener listener = new TcpListener(25543);


C#
if (listener.Pending()) {
                message = null;
                client = listener.AcceptTcpClient();

                StreamReader reader = new StreamReader(client.GetStream());

                while (reader.Peek() != -1)
                {
                    message += reader.Read().ToString();
                }

                MessageBox.Show(message);
            }


Right now, when I run this, the message that gets displayed in the MessageBox is a very long number, for the message "Test" it's "84101115116". How can I convert this integer back to the original string "Test", so that the original message is displayed correctly in my server application?

I know that e.g. 84 in ASCII is the letter T, however the other numbers are different. Can some1 help?

Greetings
~Veraner
AnswerRe: StreamReader in TcpListener Pin
Paulo Zemek2-Mar-15 7:45
Paulo Zemek2-Mar-15 7:45 
GeneralRe: StreamReader in TcpListener Pin
Member 114922552-Mar-15 8:25
Member 114922552-Mar-15 8:25 
QuestionDatagridview row replay Pin
sdfsdfsdfewrew3feff1-Mar-15 5:03
sdfsdfsdfewrew3feff1-Mar-15 5:03 
GeneralRe: Datagridview row replay Pin
Richard MacCutchan1-Mar-15 6:15
mveRichard MacCutchan1-Mar-15 6:15 
GeneralRe: Datagridview row replay Pin
sdfsdfsdfewrew3feff1-Mar-15 8:23
sdfsdfsdfewrew3feff1-Mar-15 8:23 
GeneralRe: Datagridview row replay Pin
Richard MacCutchan1-Mar-15 22:38
mveRichard MacCutchan1-Mar-15 22:38 
GeneralRe: Datagridview row replay Pin
Eddy Vluggen2-Mar-15 8:02
professionalEddy Vluggen2-Mar-15 8:02 
Questioncreating a generic factory class that handles ValueTypes ? Pin
BillWoodruff28-Feb-15 23:36
professionalBillWoodruff28-Feb-15 23:36 
AnswerRe: creating a generic factory class that handles ValueTypes ? Pin
OriginalGriff1-Mar-15 0:11
mveOriginalGriff1-Mar-15 0:11 
GeneralRe: creating a generic factory class that handles ValueTypes ? Pin
BillWoodruff1-Mar-15 1:23
professionalBillWoodruff1-Mar-15 1:23 
AnswerRe: creating a generic factory class that handles ValueTypes ? Pin
manchanx1-Mar-15 1:53
professionalmanchanx1-Mar-15 1:53 
GeneralRe: creating a generic factory class that handles ValueTypes ? Pin
BillWoodruff1-Mar-15 6:26
professionalBillWoodruff1-Mar-15 6:26 

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.