buffer

socket buffer size: pros and cons of bigger vs smaller

与世无争的帅哥 提交于 2019-12-11 12:03:49
问题 I've never really worked with COM sockets before, and now have some code that is listening to a rather steady stream of data (500Kb/s - 2000Kb/s). I've experimented with different sizes, but am not really sure what I'm conceptually doing. byte[] m_SocketBuffer = new byte[4048]; //vs byte[] m_SocketBuffer = new byte[8096]; The socket I'm using is System.Net.Sockets.Socket, and this is my constructor: new Socket(AddressFamily.InterNetwork, SocketType.Stream, ProtocolType.Tcp) My questions are:

Best approach to continuously scan for a string in a streaming buffer

ぃ、小莉子 提交于 2019-12-11 11:47:20
问题 I have this situation where my function continuously receive data of various length. The data can be anything. I want to find the best way I to hunt for particular string in this data. The solution will require somehow to buffer previous data but I cannot wrap my head around the problem. Here is an example of the problem: DATA IN -> [\x00\x00\x01\x23B][][LABLABLABLABLA\x01TO][KEN][BLA\x01]... if every [...] represents a data chunk and [] represents a data chunk with no items, what is the best

Geodjango: How to Buffer From Point

不羁的心 提交于 2019-12-11 11:36:05
问题 I want to have a radius based distance search. To do this, I want to create a buffer around a point object in order to filter objects that are inside it. Here is where I am at with it: >>> lat = 37.7762179974 >>> lon = -122.411562492 >>> from django.contrib.gis.geos import Point >>> pnt = Point(lat, lon) >>> buf = pnt.buffer(0.0001) But I am having problems filtering the Thing objects based on whether they are inside the buffer: >>> z = Thing.objects.filter(pnt__intersects=buf) ( I know that

Using an expect Script to send the output of a command and store in a file

筅森魡賤 提交于 2019-12-11 11:14:05
问题 Hi I am trying to store the output of a command run through a spawn ssh remote window into my local host, I am new to expect and am not able to figure out where I am wrong. My Code: #!/bin/bash while read line do /usr/bin/expect <<EOD spawn ssh mininet@$line expect "assword:" send -- "mininet\r" set output [open "outputfile.txt" "a+"] expect "mininet@mininet-vm:*" send -- "ls\r" set outcome $expect_out(buffer) send "\r" puts $output "$outcome" close $output expect "mininet@mininet-vm:*" send

Java―good size for a char buffer

前提是你 提交于 2019-12-11 11:13:25
问题 I am coding a little java based tool to process mysqldump files, which can become quite large (up to a gigabyte for now). I am using this code to read and process the file: BufferedReader reader = getReader(); BufferedWriter writer = getWriter(); char[] charBuffer = new char[CHAR_BUFFER_SIZE]; int readCharCout; StringBuffer buffer = new StringBuffer(); while( ( readCharCout = reader.read( charBuffer ) ) > 0 ) { buffer.append( charBuffer, 0, readCharCout ); //processing goes here } What is a

How do i access an image from the node.js sharp module buffer

旧城冷巷雨未停 提交于 2019-12-11 10:34:39
问题 I'm new to node.js and web development and have a question regarding the node.js sharp module. I want to resize/crop an image using the node.js sharp module, store it to a buffer and access it afterwards. After reading the Sharp API I came up with this code example. sharp('img.jpg').extract(extract).resize(height, width).toBuffer(function (err, data, info) {img = data;}); I thought that the variable img now contains my new image. My first question would be whether my assumption is correct. If

consumer producer code undeclared errors linux debug

冷暖自知 提交于 2019-12-11 10:25:40
问题 Trying to compile my code in linux by doing gcc -o consumer.c -lpthread -lm and I am getting compile errors about having undeclared for things I, to the best of my knowledge, have declared. Most of the undeclared seem to be related to buffers, of which this is my first program using buffers. Here are the errors (edited to reflect changes) typedef char buffer_item buffer[BUFFER_SIZE]; // asm or __attribute__ before "buffer" both of these(expected ')' before 'item' int insert_item(buffer_item

Allocate buffer dynamically for DB query according to the record actual size

戏子无情 提交于 2019-12-11 09:45:36
问题 I am using a Perl 5.8.3 script to query Oracle 11g database. The connection is established with ODBC Extension for Win32: http://search.cpan.org/~gsar/libwin32-0.191/ODBC/ODBC.pm As you can see in the documentation (link), the buffer size is limited to 10K. This size of the buffer is not sufficient in some cases (i.e. too small). Excerpt from the link above: “The amount of memory that is allocated to retrieve the field data of a record is dynamic and changes when it need to be larger.” I have

PHP time delay using ob_flush with loading message

夙愿已清 提交于 2019-12-11 09:28:26
问题 I'm running a PHP script that accesses some MySQL databases, and I need to wait a few seconds until the previous script has entered all the information into the database. The wait time shouldn't be long, but just in case servers are slow on an off day, I'm using sleep(10) to wait 10 seconds before executing the script. I wanted to display a "please wait" message, while it is waiting that 10 seconds, but unfortunately that message gets displayed only after the 10 seconds has already been

setbuf redirection

孤街醉人 提交于 2019-12-11 09:19:09
问题 I use setbuf in order to redirect stdout to char buffer But I get some side effect after it ,when I want to write to the stdout only the new data As explained in the following code: #define bufSize 100 int main() { char buf[bufSize]; setbuf(stdout, buf); printf("123"); //123 is written to the buffer setbuf(stdout,NULL); //123 is written to the stdout(unwanted side effect) printf("456"); //123456 appears in the stdout } How can I solve the problem? Other question regarding this - will this