From owner-freebsd-questions@FreeBSD.ORG Tue Feb 16 20:13:59 2010 Return-Path: Delivered-To: freebsd-questions@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 0ED501065696 for ; Tue, 16 Feb 2010 20:13:59 +0000 (UTC) (envelope-from amvandemore@gmail.com) Received: from mail-pz0-f202.google.com (mail-pz0-f202.google.com [209.85.222.202]) by mx1.freebsd.org (Postfix) with ESMTP id D49098FC1E for ; Tue, 16 Feb 2010 20:13:58 +0000 (UTC) Received: by pzk40 with SMTP id 40so3617039pzk.7 for ; Tue, 16 Feb 2010 12:13:58 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:mime-version:received:in-reply-to:references :date:message-id:subject:from:to:cc:content-type; bh=sE7XgdEbi0ut/d4iSooJu3y5FceOqewoFr6l5fTCxNE=; b=OpgGZNnKRAnxWlThIfXc0TFtJA6beTRgr4xRgNQCQA2ppBK2WmnX+YXonxjnSLPzau ptXiZ898TR4v5xxQpD1n1sdlUj71qf1z+etIQ3BUXKbFt2o7duVi977ADvTGnpq0j5g+ U/IelR1w1hR9DcQDRAJ++dqL95iAMJA1frv5Q= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=mime-version:in-reply-to:references:date:message-id:subject:from:to :cc:content-type; b=jjf5aFa+NfF9w9avQQV+CN1pJ5IHVu81ahwgDP50sOUvsEGAYRBFdhGqKu7SWQ3o7Y oh5M/9OVEIV65/hVMciF09CueFfJcaSpWcBQXJ41efnKL3o2OwEpGElR401+VHBr/IsM h+MyiW5UbjABBTRw9HuVkeC4kKw3KKpR1U7wI= MIME-Version: 1.0 Received: by 10.142.122.6 with SMTP id u6mr2733323wfc.8.1266351238307; Tue, 16 Feb 2010 12:13:58 -0800 (PST) In-Reply-To: <560f92641002161142m1e85b647u5f0870896be44958@mail.gmail.com> References: <560f92641002161142m1e85b647u5f0870896be44958@mail.gmail.com> Date: Tue, 16 Feb 2010 14:13:58 -0600 Message-ID: <6201873e1002161213n16d59089t4db9e08b7d7139bb@mail.gmail.com> From: Adam Vande More To: Nerius Landys Content-Type: text/plain; charset=ISO-8859-1 X-Content-Filtered-By: Mailman/MimeDel 2.1.5 Cc: FreeBSD Mailing List Subject: Re: netcat (/usr/bin/nc) buffer size too small - alternate utilities? X-BeenThere: freebsd-questions@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: User questions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 16 Feb 2010 20:13:59 -0000 On Tue, Feb 16, 2010 at 1:42 PM, Nerius Landys wrote: > I'm communicating with a server that uses UDP packets. The server > receives a UDP packet, and responds with a UDP packet by sending one > to the initial sender. The request packets are always very small in > size, but the response UDP packets can be up to 9216 bytes in size. > > I am using netcat like so: > > echo "$REQUEST_BODY" | /usr/bin/nc -w 1 -u "$PLAYERDB_HOST" > "$PLAYERDB_PORT" > > The response always gets truncated to 1024 bytes using netcat. > > I wrote my own silly version of netcat specifically suited to my needs > over UDP, in Java. I then call it like so: > > echo "$REQUEST_BODY" | /usr/local/bin/java SendUDP "$PLAYERDB_HOST" > "$PLAYERDB_PORT" > > (Source code at the end of this message.) > > With my Java program, I'm able to get up to 9216 bytes in my UDP > response packet; the response won't be truncated to 1024 bytes like in > netcat. > > Now I've read the netcat manpage and it says nothing about any buffer > size or ways to increase it. I don't really want to use my Java > program because starting up a JVM for each server query is very > expensive. Any ideas of any other tools like netcat that will enable > me to receive UDP packets up to 9216 bytes in size? > You can try raising OS's UDP buff size: sysctl kern.ipc.maxsockbuf=8388608 or write an equivalent app in python... -- Adam Vande More