Sponsored Content
Full Discussion: Problem with read & write
Top Forums Programming Problem with read & write Post 302087290 by EltonSky on Wednesday 30th of August 2006 08:39:04 PM
Old 08-30-2006
It's really a frustrating problem Smilie


I m trying to use 2 write() in a row, first write() is used to send file size, 2nd send the file. On client side, I use malloc() for the buf size and free later.

Current situation is if I put sth (like sleep(1) or a read()) btw 2 write() , they both work fine. Othrewise, I lose some bytes on client side which is from the 2nd write(). That makes the browser cannnot recognize the HTTP header....

REGARDS,

ELton
 

10 More Discussions You Might Find Interesting

1. Programming

read, write & STDOUT_FILENO....

hi guys, I'have a question 4 u. Why this code give me the right output (an integer on the stdout): read(fd,&mpid,sizeof(pid_t)); printf("%d\n",mpid); Instead this code give me only a blank line: read(fd,&mpid,sizeof(pid_t)); write(STDOUT_FILENO,&mpid,sizeof(pid_t)); ... (2 Replies)
Discussion started by: M3xican
2 Replies

2. UNIX for Dummies Questions & Answers

How do i access (mount, read & write) a floppy disk from the console, not being root?

welll, the title quite explains what i want to do thanks for your time! (4 Replies)
Discussion started by: kfaday
4 Replies

3. Shell Programming and Scripting

File read & execute problem

Hi folks, Need your help. I am writing a KSH script to read a few commands from a file & execute. I am using the following code to read the file line by line & excute each command. When I am printing each line I see it is printing properly but while excuting, the particular "ps" command... (5 Replies)
Discussion started by: tipsy
5 Replies

4. UNIX for Dummies Questions & Answers

user & group read/write access question

folks; I created a new users on my SUSE box and i need to give this user/group a read write access to one specific folder. here's the details: - I created new user "funny" under group "users". - I need to give this user "funny" a read/write access to another directory that is owned by "root".... (3 Replies)
Discussion started by: Katkota
3 Replies

5. UNIX for Dummies Questions & Answers

About read,write & execute permissons of a directory

Hi all, I want to know differences between read,write & execute permissons given to directory. Thanx in advance. (6 Replies)
Discussion started by: vishwasrao
6 Replies

6. Shell Programming and Scripting

Bash Script to Read & Write on different directories

Hi, root@server] df -h 121G 14G 101G 12% /home 147G 126G 14G 91% /backup We having our site files and images are storing in /backup/home/user/files/ through symbolic link created in /home directory pointing in /backup directory as following. root@server] cd /home... (1 Reply)
Discussion started by: mirfan
1 Replies

7. Shell Programming and Scripting

PHP read large string & split in multidimensional arrays & assign fieldnames & write into MYSQL

Hi, I hope the title does not scare people to look into this thread but it describes roughly what I'm trying to do. I need a solution in PHP. I'm a programming beginner, so it might be that the approach to solve this, might be easier to solve with an other approach of someone else, so if you... (0 Replies)
Discussion started by: lowmaster
0 Replies

8. IP Networking

read/write,write/write lock with smbclient fails

Hi, We have smb client running on two of the linux boxes and smb server on another linux system. During a backup operation which uses smb, read of a file was allowed while write to the same file was going on.Also simultaneous writes to the same file were allowed.Following are the settings in the... (1 Reply)
Discussion started by: swatidas11
1 Replies

9. Programming

help: problem with sockets write/read

I am trying to make a server and client, the client will choose between some options and the server will react accordingly. After a some reads and writes that work the server needs to read from client an INT i use this: read(newSd,&k,sizeof(int));But even if all the other times there was no... (1 Reply)
Discussion started by: theSling
1 Replies

10. UNIX for Dummies Questions & Answers

MAN and read & write function

How to use MAN to find information about read() and write() function ? The command "man read" show some rubbish, for example "man open" show great information about function I need. (2 Replies)
Discussion started by: bbqtoss
2 Replies
Perlbal::Manual::Debugging(3pm) 			User Contributed Perl Documentation			   Perlbal::Manual::Debugging(3pm)

NAME
Perlbal::Manual::Debugging - Debugging Perlbal VERSION Perlbal 1.78. DESCRIPTION Perlbal has two ways of debugging. One of them is through a management console; the other is through debugging messages. Debugging in a console You'll need to set up a management service and use it to dump all the information you require. The comprehensive documentation on this process can be found at Perlbal::Manual::Management. Debugging messages You can control the ammount of debugging messages Perlbal dumps by setting the environment variable "PERLBAL_DEBUG" to a value between 0 and 4: PERLBAL_DEBUG = 0 # no debug PERLBAL_DEBUG = 4 # debug everything Debug level 1 You can activate basic debug by setting "PERLBAL_DEBUG" to 1: PERLBAL_DEBUG = 1 The following debugging messages are turned on: o When a connection to a backend is closed, Perlbal::BackendHTTP prints "Backend $self is done; closing..." o When a connection to a backend is killed, Perlbal::ClientProxy prints "Client ($self) closing backend ($backend)" o When an HTTP request fails to be parsed, Perlbal::HTTPHeaders prints "HTTP parse failure: $reason" o When the connection is promoted to SSL, Perlbal::TCPListener prints " .. socket upgraded to SSL!" Debug level 2 By setting the debug level to 2 you'll get all the messages from level 1. PERLBAL_DEBUG = 2 You will also get a few others: o When a connection to a backend is opened and ready to be written to, Perlbal::BackendHTTP prints "Backend $self is writeable!" o When a response is about to be handled, Perlbal::BackendHTTP prints "BackendHTTP: handle_response" o When a backend is ready to be read from, Perlbal::BackendHTTP prints "Backend $self is readable!" o When there's an error with the connection to the backend, Perlbal::BackendHTTP prints "BACKEND event_err" o Whenever we're determining if we should be sending keep-alive header information back to the client, Perlbal::ClientHTTPBase prints "ClientHTTPBase::setup_keepalive($self)" o Whenever the client is ready for more of its file, Perlbal::ClientHTTPBase prints "REPROXY SSL done" o Right after we've read a chunk of a file and when a reproxy request is about to be sent, Perlbal::ClientHTTPBase prints "REPROXY Sent: $sent" o When we've written all data in the queue (and are about to stop waiting for write notifications), Perlbal::ClientHTTPBase prints "All writing done to $self" o Whenever a client proxy is about to be closed, Perlbal::ClientProxy prints "Perlbal::ClientProxy closed", followed by a possible "again" and a possible "saying $reason" o When a client has disconnected, Perlbal::ClientProxy prints "ClientProxy::client_disconnected" o When a backend requests a client of a high priority request and the client is available, "Service" in Perlbal prints "Got from fast queue, in front of $backlog others" o When a backend requests a client of a normal priority request and the client is available, "Service" in Perlbal prints "Backend requesting client, got PRIORITY = $cp-"{fd}.> o When a backend requests a client of a low priority request and the client is available, "Service" in Perlbal prints "Backend requesting client, got low priority = $cp-"{fd}.> o When header are being read, Perlbal::Socket prints "Perlbal::Socket::read_headers($self) is_res=$is_res" Debug level 3 PERLBAL_DEBUG = 3 By setting the debug level to 3 you'll get all the messages from level 1 and 2 plus the following: o Right before response headers are written to the client, Perlbal::BackendHTTP prints " writing response headers to client" o As we're writing to the client, Perlbal::BackendHTTP prints " content_length=VALUE" and " remain=VALUE", where the values are "undef" if they are not defined o If we're done writing to the client, Perlbal::BackendHTTP prints " done. detaching." o Whenever we're determining if we should be sending keep-alive header information back to the client, Perlbal::ClientHTTPBase prints " service's persist_client = $persist_client" o While determining if we should be sending keep-alive header information back to the client, if we were sent "content-length" or it's a head request, as we're doing a keep alive Perlbal::ClientHTTPBase prints " doing keep-alive to client" o If we're not sending keep-alive header information back ot the client, Perlbal::ClientHTTPBase prints " doing connection: close" o Right after we've finished sending all of the results to the user, Perlbal::ClientProxy prints "ClientProxy::backend_finished" o When we've sent a response to a user fully and we need to reset state, Perlbal::ClientProxy prints "ClientProxy::http_response_sent -- resetting state" o When we're writing a response to a client, Perlbal::ClientProxy prints "ClientProxy::event_write" o After writing a response to a client, if it is still connected and we're triggering trigger our backend to keep reading, Perlbal::ClientProxy prints " unstalling backend" o When reading a request, Perlbal::ClientProxy prints "ClientProxy::event_read" o When reading a request and just before we read the headers, Perlbal::ClientProxy prints " no headers. reading." o When reading a request, if we're not buffering to disk or we're no longer reading, as we disable reads, Perlbal::ClientProxy prints " disabling reads." o As we're reading, Perlbal::ClientProxy prints " reading $read_size bytes (VALUE bytes remain)", where "VALUE bytes remain" can be <undef> o After each read, Perlbal::ClientProxy prints " read $len bytes" o After we finished reading the request, Perlbal::ClientProxy prints " done_reading = $done_reading, backend = BACKEND", where "BACKEND" can be "undef" o When we send the headers to the backend and it responds before we're done reading from the client, further reads from the client are discarded; in this situation Perlbal::ClientProxy prints " already responded.". If the client continues to send data, Perlbal::ClientProxy prints " already responded [2]." and then gives up on reading o After reading, and having a backend available where we can write to, just before we do, Perlbal::ClientProxy prints " got a backend. sending write to it." o After reading, if there's no backend available, Perlbal::ClientProxy prints " no backend. read_ahead = $self-"{read_ahead}.> o If we know we've already started spooling a file to disk and we're about to continue doing so, Perlbal::ClientProxy prints " bureason = $self-"{bureason}> o If a backend wasn't available and we're about to request one, Perlbal::ClientProxy prints " finally requesting a backend" o When we're trying to read headers and the client has disconnected, Perlbal::Socket prints " client disconnected" o If we need to remove a trailing " " from the headers, Perlbal::Socket prints " throwing away leading " o If we've read a packet with headers and by the end of it we can't find the end of them, Perlbal::Socket prints " can't find end of headers" o Once we've read some headers, Perlbal::Socket prints " pre-parsed headers: [$hstr]" o After reading headers, if there's additional content that we've read, we push it back; when we do so, Perlbal::Socket prints " pushing back $len bytes after header" o If we got bogus headers, and right before we close the connection due to a parsing failure, Perlbal::Socket prints " bogus headers" o If we got valid headers, Perlbal::Socket prints " got valid headers" o If we're reading buffered data from a client, Perlbal::Socket prints "draining readbuf from $self to $dest: [$$bref]" Debug level 4 By setting the debug level to 4 you get all the messages from levels 1 to 3. Plus, "write" is redefined so that whenever "write" is called it first prints "write($self, <$clen>"$content") from ($pkg, $filename, $line)". PERLBAL_DEBUG = 4 SEE ALSO Perlbal::Manual::Configuration, Perlbal::Manual::Management. perl v5.14.2 2011-01-23 Perlbal::Manual::Debugging(3pm)
All times are GMT -4. The time now is 10:57 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy