Click here to Skip to main content
15,927,060 members
Home / Discussions / C#
   

C#

 
QuestionRe: DrawLine() does not work Pin
nilam247712-May-08 23:07
nilam247712-May-08 23:07 
AnswerRe: DrawLine() does not work Pin
Christian Graus12-May-08 23:11
protectorChristian Graus12-May-08 23:11 
QuestionAdd tool tip on graphic objects Pin
cooltoad12312-May-08 22:44
cooltoad12312-May-08 22:44 
AnswerRe: Add tool tip on graphic objects Pin
Gareth H12-May-08 22:52
Gareth H12-May-08 22:52 
AnswerRe: Add tool tip on graphic objects Pin
Christian Graus12-May-08 23:02
protectorChristian Graus12-May-08 23:02 
Questiondisapper format of richedit in microsoft word Pin
ham rez12-May-08 22:37
ham rez12-May-08 22:37 
AnswerRe: disapper format of richedit in microsoft word Pin
Christian Graus12-May-08 23:02
protectorChristian Graus12-May-08 23:02 
QuestionReceiving "raw" print jobs Pin
User 137680012-May-08 22:04
User 137680012-May-08 22:04 
Hi all,
I'm working on a project that contains a function for receiving files as "print jobs" using standard "Raw" Port9100 printing (also known as "JetDirect" printing, but this really has nothing to do with HP JetDirects).
The program should receive a print job and then save it as a file. The idea of the "Raw" protocol from everything I've read is essentially just that it is, as the name suggests, completely raw. A connection is established, the data is sent and the connection is closed. (if anyone knows differently, please let me know!)
I have some code that looks somewhat like this (inside a loop of course):
<br />
TcpListener tcpl = new TcpListener(IPAddress.Any, 9100);<br />
tcpl.Start();<br />
if (tcpl.Pending())<br />
{<br />
    Socket newSocket = tcpl.AcceptSocket();<br />
    if (newSocket.Connected)<br />
    {<br />
        NetworkStream ns = new NetworkStream(newSocket);<br />
        StreamWriter sw = new StreamWriter(filename, false);<br />
        if (ns.CanRead)<br />
        {<br />
            while (ns.DataAvailable)<br />
            {<br />
                sw.Write((char)ns.ReadByte());<br />
            }<br />
        }<br />
        sw.Close();<br />
        ns.Flush();<br />
        ns.Close();<br />
        newSocket.Close();<br />
	//Do some other stuff here to save the file and process it<br />
    }<br />
}<br />

It appears to "mostly" work. The problem is that the data I get in the file isn't exactly the data I would expect. The print job appears "mostly okay", but there is some actual corruption in the data and it won't print to the printer when passed on. The print driver is PCLXL, so I can't read it by sight (like PostScript or PCL5), but doing a comparison with a hex editor to a "print to file" of the same original, I can see massive corruption in the data itself - the PJL header (which is plain text) is totally fine. However in the data itself (after the header), there appears to be hex C3 (unsigned byte 195) interspersed right through the file.
I THINK this is probably the fault of the fact that I'm casting ns.ReadByte() to char, and it's modifying the data in some way. However, StreamWriter doesn't let me write the byte directly. I could however be wrong.
Can anyone offer another way I could do this that won't have this problem?
AnswerRe: Receiving "raw" print jobs Pin
m@u12-May-08 22:45
m@u12-May-08 22:45 
GeneralRe: Receiving "raw" print jobs Pin
User 137680012-May-08 23:36
User 137680012-May-08 23:36 
QuestionCurrent directory issue to load a assembly thru reflection Pin
shivapriyak12-May-08 21:40
shivapriyak12-May-08 21:40 
AnswerRe: Current directory issue to load a assembly thru reflection Pin
natsuyaki12-May-08 21:50
natsuyaki12-May-08 21:50 
GeneralRe: Current directory issue to load a assembly thru reflection Pin
shivapriyak12-May-08 23:25
shivapriyak12-May-08 23:25 
AnswerRe: Current directory issue to load a assembly thru reflection Pin
Spunky Coder12-May-08 21:55
Spunky Coder12-May-08 21:55 
GeneralRe: Current directory issue to load a assembly thru reflection Pin
shivapriyak12-May-08 23:20
shivapriyak12-May-08 23:20 
QuestionRe: Current directory issue to load a assembly thru reflection Pin
jpsstavares18-Sep-08 6:51
jpsstavares18-Sep-08 6:51 
QuestionVisual stodio 2008 WorkFlow Project error Pin
Thaer Hamael12-May-08 21:25
Thaer Hamael12-May-08 21:25 
AnswerRe: Visual stodio 2008 WorkFlow Project error Pin
MarkB77712-May-08 23:19
MarkB77712-May-08 23:19 
GeneralRe: Visual stodio 2008 WorkFlow Project error Pin
Thaer Hamael12-May-08 23:36
Thaer Hamael12-May-08 23:36 
AnswerRe: Visual stodio 2008 WorkFlow Project error Pin
MarkB77712-May-08 23:47
MarkB77712-May-08 23:47 
QuestionHelp with c# Pin
WebMaster12-May-08 21:08
WebMaster12-May-08 21:08 
AnswerRe: Help with c# Pin
Christian Graus12-May-08 21:15
protectorChristian Graus12-May-08 21:15 
GeneralRe: Help with c# Pin
WebMaster13-May-08 8:22
WebMaster13-May-08 8:22 
QuestionHow to get the CPU Usage of a Process Pin
Smithakrishnan12-May-08 20:39
Smithakrishnan12-May-08 20:39 
AnswerRe: How to get the CPU Usage of a Process Pin
Spunky Coder12-May-08 20:54
Spunky Coder12-May-08 20:54 

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.