Sponsored Content
Full Discussion: Socket Programming
Top Forums Programming Socket Programming Post 302105042 by Corona688 on Tuesday 30th of January 2007 10:39:55 AM
Old 01-30-2007
Quote:
Originally Posted by DaveG
Correct, the struct is just a bunch of data. Unfortunately the "char *str" element is just the memory address returned by malloc.
It's worse than that, the string is a pointer to a memory constant.
 

10 More Discussions You Might Find Interesting

1. Programming

Socket Programming

Dear Reader, Is there any way to check up socket status other than 'netstatus ' Thanks in advance, (1 Reply)
Discussion started by: joseph_shibu
1 Replies

2. Programming

Socket Programming socket

Hello, I actually try to make client-server program. I'm using SCO OpenServer Release 5.0.0 and when I try to compile my code (by TELNET) I've got this error : I'm just using this simple code : and I get the same error if I use : If someone can help me, Thanks (2 Replies)
Discussion started by: soshell
2 Replies

3. Programming

Need Help Regarding Socket Programming

Can anyone plz me. I need a sample code for the following description. Its urgent. It is C/Socket program with the following descriptions: NAME coreadServer - Concurrent Readers Server. coreadClient - Concurrent Readers Client. SYNOPSIS coreadServer <OutputFile> coreadClient <n>... (1 Reply)
Discussion started by: priya.vmr
1 Replies

4. IP Networking

socket programming

my system is a stand alone system... i want to try doing socket porgramming..ihave heard that this is usually done during testing... how can i do that....? (6 Replies)
Discussion started by: damn_bkb
6 Replies

5. IP Networking

socket programming

Hello Everyone Iam working on tcp/ip programming.with some time interval server has to send data.client has to close the connection and to open the connection between the time interval.this is the scenario when iam closing the connection in client side the connection terminates.how to... (1 Reply)
Discussion started by: sureshvaikuntam
1 Replies

6. Programming

help regarding socket programming

i m using sockets for setting up a connection between a server and a client. When the clients gets connected to the server, its ip is conveyed to the server through one of the predefined structures in c library... i save this ip address in an array....1st client's ip address goes to the zeroth... (1 Reply)
Discussion started by: abmxla007
1 Replies

7. UNIX for Advanced & Expert Users

socket programming

can we send udp message to a destination ip address .. without having an ip address configured in our machine using recvfrom ? (2 Replies)
Discussion started by: Gopi Krishna P
2 Replies

8. UNIX for Dummies Questions & Answers

hi i need help with socket programming

in socket programming how can i : Create for example 3 blank files, namely: server, client, network •Server: act as servers/provider, will receive all requests from different client •Client: requesters •Network: middle-layer of communication between server & client any tips or... (6 Replies)
Discussion started by: kedah160
6 Replies

9. Programming

Socket programming

Hi everyone, I'm new to this forum. I'm working on new project for last few days and this forum already helped me on couple of occasions. I don't have any prior experience with network programming so I'll appreciate any advise given. I'm trying to do the following: 1. open user... (2 Replies)
Discussion started by: _thomas
2 Replies

10. Programming

socket programming

how to include socket.h in visual studio 2005.. (2 Replies)
Discussion started by: asd123
2 Replies
MALLOC(9r)																MALLOC(9r)

NAME
MALLOC - General: Allocates a variable-size section of kernel virtual memory SYNOPSIS
#include <sys/malloc.h> MALLOC( addr, cast, u_long size, int type, int flags ); ARGUMENTS
Specifies the memory pointer that points to the allocated memory. You specify the addr argument's data type in the cast argument. Speci- fies the data type of the addr argument and the type of the memory pointer returned by MALLOC. Specifies the size in bytes of the memory to allocate. Typically, you pass the size as a constant to speed up the memory allocation. Specifies the purpose for which the memory is being allocated. The memory types are defined in the file <malloc.h>. Typically, kernel modules use the constant M_DEVBUF to indicate that kernel module memory is being allocated (or freed). Specifies one of the following flag constants defined in /usr/sys/include/sys/mal- loc.h: Allocates memory from the virtual memory subsystem if there is not enough memory in the preallocated pool. This constant signifies that MALLOC can block. Does not allocate memory from the virtual memory subsystem if there is not enough memory in the preallocated pool. This constant signifies that MALLOC cannot block. Allocates zero-filled memory. You pass this bit value by ORing it to M_WAITOK or M_NOWAIT. DESCRIPTION
The MALLOC routine (macro) allocates at least size bytes from the kernel memory and returns the address of the allocated memory. A kernel module can allocate the memory in interrupt and process contexts. The MALLOC routine (macro) maintains a pool of preallocated memory for quick allocation. If there is not enough memory in the pool, MALLOC allocates memory from the virtual memory subsystem by calling kmem_alloc, which can potentially block (sleep). A kernel thread that allo- cates and frees memory to and from the preallocated pool. The MALLOC routine (macro) is actually a wrapper that calls malloc. A kernel module should not directly call the MALLOC routine. The type argument allows the memory allocator to keep track of memory usage by a subsystem. If the allocation size is greater than 16K, you must pass M_WAITOK to the flags argument. You cannot allocate more than 16K bytes of memory in interrupt context. NOTES
A memory corruption can occur if a device driver continues to use the memory after freeing it. The operating system provides a built-in mechanism to debug such erroneous use of memory. You can enable this debugging feature at boot time by providing the following boot parame- ter: kmem_debug=1. When you enable this debugging feature, the FREE routine stores the following in the last word of freed memory: The pro- gram counter (pc) of the module that last freed the memory The checksum of the memory content The MALLOC routine checks the checksum of the memory content before reallocating this corrupted memory. If the checksum of the memory con- tent does not match the corrupted memory, MALLOC stores the debug information and then causes the kernel to panic. The MALLOC routine stores the address and size of the corrupted memory and the pc of the routine that last freed it in a kmem_corrupt_data structure. You should consider the following when using this debugging feature: This debugging feature does not detect cases where the corruption occurs after MALLOC reallocates the freed memory to some other module. There is a small chance that the pc of the routine that freed the memory (stored in the last word of freed memory) may itself become corrupted. CAUTIONS
A device driver must not call MALLOC in interrupt context with the flags argument set to M_WAITOK. If flags is set to M_WAITOK, MALLOC checks if the kernel thread is in interrupt context. If so, MALLOC returns a null pointer and displays a message on the console terminal. The M_WAITOK flag implies that it is valid to allocate memory from the virtual memory subsystem if there is not enough memory in the preal- located pool. To be able to allocate memory from the virtual memory subsystem (which can page fault), the device driver must be in process context. RETURN VALUES
Upon successful completion, MALLOC returns the address of the allocated memory. The return type associated with this address is the same as that specified for the addr argument. If the memory allocation request cannot be fulfilled, MALLOC returns a null pointer in the addr argument. SEE ALSO
Routines: FREE(9r) MALLOC(9r)
All times are GMT -4. The time now is 10:21 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy