Ruby Networking Quiz
Question 1: Net::HTTP Basics
Which method would you use to make a simple GET request to 'https://api.example.com/users' using Net::HTTP?
Question 2: TCP vs UDP
What is the main difference between TCP and UDP protocols?
Question 3: TCPServer
What does the following code do?
server = TCPServer.new('localhost', 3000)
client = server.accept
Question 4: URI Parsing
Given the URL 'https://api.example.com:8080/v1/users?active=true#section1', what would URI.parse(url).port return?
Question 5: open-uri
Which is the correct way to open a URL with custom headers using open-uri?
Question 6: UDPSocket
What happens when you call send on a UDPSocket?
Question 7: Query Parameters
How do you properly encode query parameters containing special characters for a URL?
Question 8: Error Handling
Which exception should you catch when handling HTTP errors with open-uri?
Question 9: Socket Programming
What is the purpose of calling bind on a socket?
Question 10: Web Scraping Best Practices
Which of the following is NOT a best practice for web scraping?