Comments (6)
Yeah, the readme is outdated. This is better accomplished by doing the reading yourself and then using ParseBuffer
. Probably ParseReader
should not exist either, but now it does. :)
from ipfix.
Hm. But how do i know, how big a buffer i should use? So i don't run into short read - malformed packet?
from ipfix.
from ipfix.
Oh, right. But with such a big buffer i'm getting unexpected EOF.
Sorry for bothering you, but what am i doing wrong?
package main
import (
"net"
"log"
"fmt"
"github.com/calmh/ipfix"
)
func main() {
pc, err := net.ListenPacket("udp", ":2055")
if err != nil {
log.Fatal(err)
}
defer pc.Close()
s := ipfix.NewSession()
i := ipfix.NewInterpreter(s)
buffer := make([]byte, 65507)
for {
pc.ReadFrom(buffer)
msg, err := s.ParseBuffer(buffer)
if err != nil {
panic(err)
}
var fieldList []ipfix.InterpretedField
for _, record := range msg.DataRecords {
fieldList = i.InterpretInto(record, fieldList)
fmt.Println(fieldList)
}
}
}
from ipfix.
You need to only give it the part of the buffer that was actually read into. See the example I just wrote up in the readme in the commit linked above^ and see if that helps
from ipfix.
Yep, that definitely helps. Thank you!
from ipfix.
Related Issues (6)
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from ipfix.