Posts

Showing posts with the label tcp

How to get the size of available TCP data?

Image
Clash Royale CLAN TAG #URR8PPP How to get the size of available TCP data? Problem I have a use case where I need to Peek at exactly the first TCP packet, whatever length it may be. Peek Snippet I would have expected this to work: conn, err := sock.Accept() if nil != err { panic(err) } // plenty of time for the first packet to arrive time.Sleep(2500 * 1000000) bufConn := bufio.NewReader(conn) n := bufConn.Buffered() fmt.Fprintf(os.Stdout, "Size of Buffered Data %dn", n) However, even though I am positive that the data has arrived it still shows that 0 bytes are buffered. Full Test Application Here's a full test program: package main import ( "bufio" "fmt" "net" "os" "strconv" "time" ) func main () { addr := ":" + strconv.Itoa(4080) sock, err := net.Listen("tcp", addr) if nil != err { panic(err) } conn, err := sock.Accept() if nil != e...

How does one test net.Conn in unit tests in Golang?

Image
Clash Royale CLAN TAG #URR8PPP How does one test net.Conn in unit tests in Golang? I'm currently looking into creating some unit tests for net.Conn interface in Go, as well as other functions that build up on top of that functionality, and I'm wondering what is the best way to unit test that in Google Go? My code looks like: conn, _:=net.Dial("tcp", "127.0.0.1:8080") ... fmt.Fprintf(conn, "test") ... buffer:=make(byte, 100) conn.Read(buffer) Is the most efficient way of testing this code and the code that uses these functions to spin up a separate goroutine to act like the server, use net.http.httptest package, or something else? Suggest reading the source for the tests for the actual net library. I have picked up plenty of tips by doing that in the past. Secondly as you have already mentioned use the httptest package. – miltonb Jun 7 '15 at 4:31 ...

RDP Port C# - C#/.NET 4.x

Image
Clash Royale CLAN TAG #URR8PPP RDP Port C# - C#/.NET 4.x I'm developing RDP Helper, it's simple program, which will connect to the remote server by ip, port, username, password. Screenshot But, there's one problem, this program can connect only to 3389 port, as you can see I have added textBox, which named Port. I found information about specific port for RDP Client, but it isn't working. rdp.Server = txtIP.Text; rdp.UserName = txtUsername.Text; rdp.AdvancedSettings.RDPPort = txtPort; //Error there// IMsTscNonScriptable secured = (IMsTscNonScriptable)rdp.GetOcx(); secured.ClearTextPassword = txtPassword.Text; rdp.Connect(); Error Sorry if translate is crooked, I'm russian. How can i fix it? By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to...