buffer

Which methods implement the buffer interface in Python?

I have a custom class with a serialize method, and I want to be able to write this class directly to files and have the return value of the serialize method get written, in Python 2.6. (I'm not trying to pickle my objects, this is something totally different.) For example: class Foo(object): def serialize(self): return "Hel...

Java OpenGL Vertex Buffer Objects not working

I tried to implement Open GLs Vertex Buffer Objects the first time, and all i get is a black screen. I tried it with glOrtho instead of glPerspective, but it didnt work as well. thanks for helping Heres my code: public class VBufferTest { public static final int WIN_WIDTH = 640; public static final int WIN_HEIGHT = 480; public in...

Specifying UDP receive buffer size at runtime in Linux

Hello, In Linux, one can specify the system's default receive buffer size for network packets, say UDP, using the following commands: sysctl -w net.core.rmem_max=<value> sysctl -w net.core.rmem_default=<value> But I wonder, is it possible for an application (say, in c) to override system's defaults by specifying the receive buffer si...

generate a window for ascii game

Hello all Im trying to write an ascii game for an assignment. The program must be written entirely in c, no c++. How can i get the program to open a window capable of rendering ascii art? I want to create a window of a certain size, that is capable of printing in multiple colors. A simple console window is insufficient. Also, on a rela...

What are some tips for buffer usage and tuning in custom TCP services?

I've been researching a number of networking libraries and frameworks lately such as libevent, libev, Facebook Tornado, and Concurrence (Python). One thing I notice in their implementations is the use of application-level per-client read/write buffers (e.g. IOStream in Tornado) -- even HAProxy has such buffers. In addition to these a...

Receive buffer size for tcp/ip sockets

What's the maximum data size one should expect in a receive operation? The data that has to be sent is very large, but at some point there will be packet fragmentation I guess? ...

C: Using a select call, when I am reading, how do I keep track of the data?

First of all, I've never worked with C before (mostly Java which is the reason you'll find me write some naive C code). I am writing a simple command interpreter in C. I have something like this: //Initialization code if (select(fdmax+1, &read_fds, NULL, NULL, NULL) == -1) { perror("Select dead"); exit(EXIT_FAILURE); } .... .....

Any tutorial to understand Streams, Buffers and their usage in Java?

I have been coding Java for a while, but I have to admit that I don't get streams, buffers, etc. 100% I have tried to find a good tutorial on the subject that explains the reasoning behind them and their patterns of usage, but I couldn't find any. Only short, isolated snippets that don't help. Is there something out there? ...

How to clear shell buffer in Terminal in Mac OS X?

I know 'clear' command clears current screen, but the cleared contents just scrolled up. Is there a way to clear all cleared buffer contents? I'm figuring this to prevent scrolling up on Terminal. ---(edit)--- I'm finding a way which can be used in shell script. Or program. ...

emacs programmatically change window size

hi. I would like to implement automatic collapse of compilation buffer to small size (but not close at a delete windows), such that upon successful compilation to window is shrunk to minimum size. get-buffer-create returns a buffer. how can I shrink-window on window associated with that buffer? also, is there a way to store previous w...

emacs lisp, how to get buffer major mode?

hey guys I have tried to search Google and look in the manual, but still cannot find how to get major mode of a buffer object. Can you help me with an example or a reference. Thanks only solution I could find was to query major-mode after changing the buffer and then changing back to original buffer. Is there a better way to do it? ...

Java clearing the string buffer after loop

How do you clear the string buffer in Java after a loop so the next iteration uses a clear string buffer? ...

Java: Using type punning on primitive arrays?

Hello, everyone! I need to be able to convert byte arrays to/from other primitive type arrays, but instead of casting, I need type punning. Correct term for raw copy without casting? I thought it would be possible to do the following: // idea: byte[12] -> int[3], and int[3] -> byte[12] int[] ints; ByteBuffer bb = ByteBuffer.wrap( ...

Growable buffer for plain C

I need an open-source (preferably MIT-licensed) light-weight growable buffer implemented in plain C (preferably also compileable as C++). I need API equivalent to following (pseudo-code): void set_allocator(buffer * buf, allocator_Fn fn); void push_bytes(buffer * buf, const char * bytes, size_t len); size_t get_length(buffer * buf); v...

Does a StringBuilder initialized with a string contain exactly (only) enough space for that string?

I'm wondering if this code ... StringBuilder sb = new StringBuilder("Please read the following messages."); ... initializes sb with a buffer exactly as large as the string passed to the constructor. On the one hand, this would seem the most logical thing. On the other hand, it seems to kind of defeat the purpose of the StringBuilder c...

Can I measure the necessary buffer for sprintf in Microsoft C++?

I'm writing a small proof-of-concept console program with Visual Studio 2008 and I wanted it to output colored text for readability. For ease of coding I also wanted to make a quick printf-replacement, something where I could write like this: MyPrintf(L"Some text \1[bright red]goes here\1[default]. %d", 21); This will be useful becaus...

Buffer growth strategy

I have a generic growing buffer indended to accumulate "random" string pieces and then fetch the result. Code to handle that buffer is written in plain C. Pseudocode API: void write(buffer_t * buf, const unsigned char * bytes, size_t len);/* appends */ const unsigned char * buffer(buffer_t * buf);/* returns accumulated data */ I'm th...

Saving a 32 bit RGBA buffer into a .png file (Cocoa OSX)

I need to save the contents of a pixel editor application into a .png file but I am having trouble finding the best way to accomplish this. The pixel data is stored in a 32 bit RGBA buffer. Can anyone suggest any good tools I could use to accomplish this? EDIT: Unfortunately, CGImage and representationUsingType: are not supported by...

Patching an EXE using IDA

Say there is a buggy program that contains a sprintf() and i want to change it to a snprintf so it doesn't have a buffer overflow.. how do I do that in IDA?? ...

How to dynamically allocate buffer for receiving UDP socket (VB.Net)

A friend and I are working on a project where we're required to build a reliable UDPclient/server using VB.Net. We have things working well, but one thing that still eludes us is how to dynamically allocate a (byte) buffer for the incoming data. Right now we have to hard code a maximum value/MTU (or use a really large buffer size and r...