This is a creation in Article, where the information may have evolved or changed.
Android Peer two articles:
http://blog.csdn.net/gophers/article/details/38060307
http://blog.csdn.net/max2005/article/details/12237905
Official Document: Http://developer.android.com/training/connect-devices-wirelessly/wifi-direct.html
Golang,
http://blog.csdn.net/gophers/article/details/37815009
- Func (SRV *server) Serve (l net. Listener) Error {
- Defer L.close ()
- var tempdelay time. duration
- // This cycle is the main cycle of the server, through the incoming listener receive requests from the client and establish a connection,   
- // then creates routine for each connection to execute C.serve (), this c.serve is the specific service that handled   
- for  {  
- rw, e := l.accept ()
- if e != nil {
- if ne, ok := e. (NET. Error); ok && ne. temporary () {
- if tempdelay == 0 {
- tempdelay = 5 * time. millisecond
- } else  {  
- tempdelay *= 2   
- }
- if  MAX :=  Span class= "number" style= "margin:0px; padding:0px; Border:none; Color:rgb (192,0,0); Background-color:inherit ">1 * time. second; tempdelay > max {
- Tempdelay = max
- }
-   SRV.LOGF (" Http: accept error: %v; retrying in %v " , e, tempdelay)
- time. Sleep (Tempdelay)
- continue   
- }
- return  E  
-         }  
- tempdelay = 0   
- c, err := srv.newconn (rw)
- if err != nil {
- continue   
-         }  
- c.setstate (C.rwc, StateNew) before serve can return   
- go c.serve () // <-here for each established connection to create a routine after the service &NBSP;&NBSP;
- }
- }
Line 30th means that the data returned by the thread is processed, so go generally has a lot of threads