08-30-2006
It's really a frustrating problem
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
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
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
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
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
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
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
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
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
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
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
LEARN ABOUT NETBSD
fmemopen
FMEMOPEN(3) BSD Library Functions Manual FMEMOPEN(3)
NAME
fmemopen -- open a stream that points to the given buffer
LIBRARY
Standard C Library (libc, -lc)
SYNOPSIS
#include <stdio.h>
FILE *
fmemopen(void *restrict buffer, size_t size, const char *restrict mode);
DESCRIPTION
The fmemopen() function associates a stream with the given buffer and size. The buffer can be either NULL, or must be of the given size. If
the buffer is NULL, a buffer of the given size will be dynamically allocated using malloc(3) and freed when fclose(3) is called.
The mode argument has the same meaning as in fopen(3).
The stream treats the buffer as it would treat a file tracking the current position to perform I/O operations. For example, in the beginning
the stream points to the beginning of the buffer, unless a was specified in the mode argument, and then it points to the first NUL byte. If
a NULL buffer was specified, then the stream will always point at the first byte of the buffer.
The stream also keeps track of the size of the buffer. The size is initialized depending on the mode:
r/r+ Set to the size argument.
w/w+ Set to 0.
a/a+ Set to the first NUL byte, or the size argument if one is not found.
Read or write operations advance the buffer, but not to exceed the given size of the buffer. Trying to read beyond the size of the buffer
results in EOF returned. NUL bytes are read normally. Trying to write beyond the size of the buffer has no effect.
When a stream open for writing is either flushed or closed, a NUL byte is written at the current position or at the end of the current size
as kept internally, if there is room.
RETURN VALUES
Upon successful completion, fmemopen() returns a FILE pointer. Otherwise, NULL is returned and the global variable errno is set to indicate
the error.
ERRORS
[EINVAL] The size was 0; or the mode argument is invalid; or the buffer argument is NULL and the mode argument does not specify a
+.
The fmemopen() function may also fail and set errno for any of the errors specified for the routine malloc(3).
SEE ALSO
fclose(3), fflush(3), fopen(3), malloc(3)
STANDARDS
The fmemopen() function conforms to IEEE Std 1003.1-2008 (``POSIX.1'').
HISTORY
The fmemopen() functions first appeared in NetBSD 6.0.
BSD
October 15, 2011 BSD