| 
									
										
										
										
											2008-11-11 14:14:39 -05:00
										 |  |  | ! Copyright (C) 2008 Slava Pestov. | 
					
						
							|  |  |  | ! See http://factorcode.org/license.txt for BSD license. | 
					
						
							| 
									
										
										
										
											2009-05-30 20:15:53 -04:00
										 |  |  | USING: accessors calendar calendar.format io io.encodings.ascii | 
					
						
							|  |  |  | io.servers.connection threads ;
 | 
					
						
							| 
									
										
										
										
											2008-11-11 14:14:39 -05:00
										 |  |  | IN: time-server | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | : handle-time-client ( -- )
 | 
					
						
							|  |  |  |     now timestamp>rfc822 print ;
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | : <time-server> ( -- threaded-server )
 | 
					
						
							| 
									
										
										
										
											2009-05-30 20:15:53 -04:00
										 |  |  |     ascii <threaded-server> | 
					
						
							| 
									
										
										
										
											2008-11-11 14:14:39 -05:00
										 |  |  |         "time-server" >>name | 
					
						
							|  |  |  |         1234 >>insecure | 
					
						
							|  |  |  |         [ handle-time-client ] >>handler ;
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | : start-time-server ( -- threaded-server )
 | 
					
						
							|  |  |  |     <time-server> [ start-server ] in-thread ;
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | MAIN: start-time-server |