473,385 Members | 1,622 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,385 software developers and data experts.

0 bytes?

using System.Net.Sockets;

public bool SendBytesToPrinter(byte[] p)
{
try
{
Socket socket;
using (socket = new Socket(
AddressFamily.InterNetwork, SocketType.Stream, ProtocolType.Tcp))
{
SocketError clsError;
socket.Connect("localhost", 123);
socket.Send(p, 0, p.Length, SocketFlags.None, out clsError);
socket.Close();
}
return true;
}
catch (Exception e)
{
Response.Write(e.Message);
//TODO: do something with exception
return false;
}
}

----------------------------------------------------
ButtonClick
byte[] bMessage = System.Text.Encoding.ASCII.GetBytes("testando!");
if (SendBytesToPrinter(bMessage))
{
Response.Write("Data sent!");
}

Why my VB 6 app WinSock control DataArrival event returns 0 byte?

Thanks
Something wrong with VB or asp.net 2.0 C# VS 2005?
Jun 27 '08 #1
1 1213
Thank you to all it already worked!

"Paulo" <er********@terra.com.brescreveu na mensagem
news:OB**************@TK2MSFTNGP04.phx.gbl...
using System.Net.Sockets;

public bool SendBytesToPrinter(byte[] p)
{
try
{
Socket socket;
using (socket = new Socket(
AddressFamily.InterNetwork, SocketType.Stream, ProtocolType.Tcp))
{
SocketError clsError;
socket.Connect("localhost", 123);
socket.Send(p, 0, p.Length, SocketFlags.None, out clsError);
socket.Close();
}
return true;
}
catch (Exception e)
{
Response.Write(e.Message);
//TODO: do something with exception
return false;
}
}

----------------------------------------------------
ButtonClick
byte[] bMessage = System.Text.Encoding.ASCII.GetBytes("testando!");
if (SendBytesToPrinter(bMessage))
{
Response.Write("Data sent!");
}

Why my VB 6 app WinSock control DataArrival event returns 0 byte?

Thanks
Something wrong with VB or asp.net 2.0 C# VS 2005?

Jun 27 '08 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

10
by: Kristian Nybo | last post by:
Hi, I'm writing a simple image file exporter as part of a school project. To implement my image format of choice I need to work with big-endian bytes, where 'byte' of course means '8 bits', not...
19
by: Lorenzo J. Lucchini | last post by:
My code contains this declaration: : typedef union { : word Word; : struct { : byte Low; : byte High; : } Bytes; : } reg;
8
by: ranjeet.gupta | last post by:
Dear All I am not able o understand the exact number of bytes allocation done by the two fucntion given below, It is said that the fuction Condition_String1 allocates the 240 bytes while...
1
by: | last post by:
one thing to keep in mind is that i've written multiple tcp apps in .net 2002 and 2003, and haven't seen this problem before. I have a simple socket app where a client sends some # of bytes to...
13
by: Shailesh Humbad | last post by:
Here is an advanced PHP question. Can anyone think of a way to detect the number of bytes written to output when a script is aborted? I am sending a large file to the client, and I want to record...
5
by: philip | last post by:
Here is some lines of code than I wrote. You can copy/paste theis code as code of form1 in a new project. My problem is this one : I try to write in a file a serie of bytes. BUT some bytes...
4
by: Lee Crabtree | last post by:
I need to shift all of the values in a byte array by more than 8 bits, meaning that values should flow from one byte to another. Since I don't know in advance how many bits will be shifting, I...
7
by: BogusException | last post by:
Why is it that VS 2005, VC++.NET needs 12 bytes to store an int, when it can be done natively with 4? Mind you, even on 64-bit systems the int is still supposed to be 4 bytes. An yes, the _pointer_...
11
by: Freddy Coal | last post by:
Hi, I'm trying to read a binary file of 2411 Bytes, I would like load all the file in a String. I make this function for make that: '-------------------------- Public Shared Function...
9
by: vineeth | last post by:
Hello all, I have come across a weird problem, I need to determine the amount of bytes read from a file, but couldn't figure it out , My program does this : __ file = open("somefile") data =...
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.